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>
If width doesn't work, I prefer to use min-width
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
If your style doesn't work then you can use CSS properties
! important
If the class cannot access the style then you can use id because id is more powerful
If you don't want to use !important then you can access it through the parent tag/ClassName
If it cannot be accessed through the parent class, it can be accessed through the id. Because id is more powerful than class
Otherwise use !important if the parent class cannot access it either