简体   繁体   中英

datatables.net column width in % and px

i am using datatables.net and need to have some columns with fixed width and others to divide the remaning space in %

this is my code

{ "sName": "ragsoc_denom", "sWidth": "100%"},
{ "sName": "piva", "sWidth": "80px"},
{ "sName": "telefono", "sWidth": "100px"},
{ "sName": "indirizzo", "sWidth": "100px"},
{ "sName": "cap", "sWidth": "50px"},
{ "sName": "citta", "sWidth": "50px"},
{ "sName": "id", "sWidth": "70px"}

but it doesn't work, the percentage tables take all available space and the fixed width ones get streched to minimum

尝试设置“bAutoWidth”:false,

If you do not care how the remaining % is dispersed you could leave it up to datatables by setting the remaining sWidths to null.

If you do care how the remaining % are split up can you do this dynamically at runtime by taking the total static px (in this example 450px) subtract it from the current width of the table and then use that as a guide to determine the remaining percentages for the columns.

For example if i had a datatable that was 1000px

1000 - 450 = 550

I want a column which is 10% of the remaining

550px of 1000px = 55% left so 10% of 55% = 5.5%

如果仍然使用为初始问题列出的代码,我认为问题可能与第一列设置为占用100%的空间有关...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM