jQuery DataTables 1.10服务器端处理列

jQuery DataTables 1.10 server side processing columns

本文关键字:处理 服务器端 DataTables jQuery      更新时间:2023-09-26

在进行服务器端处理时,我很难保留列定义。我已经查看了http://datatables.net/网站,没有看到任何明显的,我可以尝试。我试过使用AJAX选项和回调,但这也没有格式化它。以下是我的javascript当前的样子。

$(this).dataTable({ sPaginationType: "full_numbers", bJQueryUI: true, processing: true, bServerSide: true, sAjaxSource: $(this).data('source'), columns: [ { width: "10%" }, { width: "20%" }, { width: "70%" } ] });

如果删除sAjaxSourcebServerSide节点,则会正确格式化列。使右侧列具有最大宽度。如果我把这些行放回去,它就不会进行任何格式化。

任何帮助都会很棒。

我终于弄明白这里发生了什么。如果你试图像我在上面所做的那样将百分比传递给dataTable,它似乎不起作用。这是因为它在应用它们之前将它们协调到像素。所以在我的情况下,它似乎不起作用,因为它会在像素用完后自动调整大小。这样做的解决方案是传入一个数字,并且只传入要调整大小的列。像这样的东西如预期的那样工作。

$(this).dataTable({ sPaginationType: "full_numbers", bJQueryUI: true, processing: true, bServerSide: true, sAjaxSource: $(this).data('source'), columns: [ null, null, { width: "150" } ] });