[英]How to align sorting image with DataTable's column header in datatable definition?
我创建了一个带有数据表的页面。 但是,当显示数据表时,排序图像出现在下一行:
这是表的定义方式:
$("#tblTable").dataTable(
{
"sDom": 't<"F"i>',
"aoColumns": [
{"sWidth": "17%", "sType": "string", "bSortable": true },
{"sWidth": "10%", "sType": "string", "bSortable": true },
{"sWidth": "15%", "sType": "string", "bSortable": true },
{"sWidth": "58%", "sType": "string", "bSortable": false}
],
"sScrollY": "180px",
"bPaginate": false,
"bFilter": false,
"aaSorting": [],
"bAutoWidth": false,
"bInfo": true,
"bJQueryUI": true
});
有可能将其固定在桌子的内部吗?
是的...您可以像这样调整每列使用的总数的百分比:
"aoColumns": [
{"sWidth": "15%", "sType": "string", "bSortable": true},
{"sWidth": "15%", "sType": "string", "bSortable": true },
{"sWidth": "15%", "sType": "string", "bSortable": true },
{"sWidth": "55%", "sType": "string", "bSortable": false}
],
看起来您的第二列太窄了,只有10%。
或者,您可以删除所有sWdith
设置并将bAutoWidth
切换为true
( "bAutoWidth": true,
)
我找到了解决方案:基本上,呈现数据表时,排序箭头部分由span
区域表示: <span class="DataTables_sort_icon css_right ui-icon ui-icon-carat-2-ns" style="vertical-align: middle; display: inline-block;"
我必须将$('.ui-icon').css('display', 'inline-block')
到数据表定义中。
这为我解决了。
希望能对某人有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.