Tab remove or disable inline styles
P粉032649413
P粉032649413 2024-03-29 22:05:08
0
1
291

I added classes to the cells to change the default width, height, etc…. Now in action, the cell still retains the default inline style. If it is width.

How to remove/disable default inline styles? !

 var tabledata = [
    {id:1, name:"Oli Bob", age:"12", col:"red", dob:""},
    {id:2, name:"Mary May", age:"1", col:"blue", dob:"14/05/1982"},
    {id:3, name:"Christine Lobowski", age:"42", col:"green", dob:"22/05/1982"},
    {id:4, name:"Brendon Philips", age:"125", col:"orange", dob:"01/08/1980"},
    {id:5, name:"Margret Marmajuke", age:"16", col:"yellow", dob:"31/01/1999"},
 ];
 
 var table = new Tabulator("#example-table", {
    data:tabledata, //assign data to table
    columns:[ //Define Table Columns
    {title:"Name", field:"name", cssClass:"custom-width"},
        {title:"Name", field:"name"},
        {title:"Age", field:"age", hozAlign:"left", formatter:"progress"},
        {title:"Favourite Color", field:"col"},
        {title:"Date Of Birth", field:"dob", sorter:"date", hozAlign:"center"},
    ],
});
.custom-width{
  width:150px
}
<link href="https://unpkg.com/tabulator-tables@5.4.3/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@5.4.3/dist/js/tabulator.min.js"></script>

<div id="example-table"></div>

P粉032649413
P粉032649413

reply all(1)
P粉242741921

If width doesn't work, I prefer to use min-width

.custom-width{
   min-width: 200px;
}

It works fine, otherwise you can check the following options.

If you want to limit the width, then you can also use max-width and min-width

.custom-width{
   min-width: 200px;
   max-width: set max width

}

If your style doesn't work then you can use CSS properties

! important

.custom-width{
    width: 150px !importnat;
}

If the class cannot access the style then you can use id because id is more powerful

#custom-width{
    // your code
}

If you don't want to use !important then you can access it through the parent tag/ClassName

.parent-class .custom-width{
  // Your Code
}

If it cannot be accessed through the parent class, it can be accessed through the id. Because id is more powerful than class

#id .custom-width{
    width: 150px;
}

Otherwise use !important if the parent class cannot access it either

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!