admin管理员组文章数量:1290935
i am using datatables 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
i am using datatables 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
Share Improve this question edited Oct 17, 2011 at 19:31 Keith.Abramo 6,9652 gold badges33 silver badges46 bronze badges asked Oct 4, 2011 at 10:18 max4evermax4ever 12.1k13 gold badges79 silver badges118 bronze badges 2- Would you please post any code which wraps around your table, any div tags etc – Anagio Commented Oct 19, 2011 at 22:02
- You may want to try adding "sClass": "someclass" to the fixed columns, then in your style sheet set the class to !important and set their width from your style sheet instead of using sWidth. – Anagio Commented Oct 19, 2011 at 22:06
3 Answers
Reset to default 3Try setting "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%
If the code listed for the initial question is still being used, I'm thinking the problem may have something to do with the first column being set to take up 100% of the space...
本文标签: javascriptdatatablesnet column width inand pxStack Overflow
版权声明:本文标题:javascript - datatables.net column width in % and px - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741521396a2383204.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论