【问题标题】:jQuery DataTables 1.10 server side processing columnsjQuery DataTables 1.10 服务器端处理列
【发布时间】:2014-09-13 17:44:08
【问题描述】:

我在进行服务器端处理时无法保留列定义。我查看了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 节点,它会正确格式化列。给右列最大宽度。如果我把这些行放回去,它不会做任何格式化。

任何帮助都会很棒。

【问题讨论】:

  • 这里的“这个”是什么?
  • 这是元素。所以基本上 $('.my-data-table')
  • 所以我假设您正在获取数据但格式不干净?
  • 是的,数据恢复正常。我也可以对其进行排序/搜索。但是,我无法让列改变它们的宽度。

标签: javascript jquery datatables


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2021-05-21
    • 2011-01-13
    • 1970-01-01
    • 2011-04-01
    • 2018-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多