【问题标题】:Equivalent of mRender with sorting based on underlying data in Jquery Datatables相当于 mRender 与基于 Jquery Datatables 中的基础数据进行排序
【发布时间】:2015-03-19 11:15:21
【问题描述】:

在 jQuery Datatable 插件中,我使用 mRender 属性来呈现数据,而不更改底层数据。 http://legacy.datatables.net/ref#mRender

它非常有用,但我想使用基础数据对列进行排序,而不是基于显示在表格中的格式化字符串。

你知道它存在一个属性或解决方案吗?

感谢您的帮助。

【问题讨论】:

    标签: javascript jquery sorting datatables jquery-datatables


    【解决方案1】:

    mRender 已重命名为 columns.render。您可以在此处查看 DataTables 1.10 中您可能在 1.9 中使用的所有内容的等效名称:http://www.datatables.net/upgrade/1.10-convert

    来自文档 (http://datatables.net/reference/option/columns.render) 的 columns.render 示例:

    以逗号分隔的列表:

    $('#example').dataTable( {
      "ajaxSource": "sources/deep.txt",
      "columns": [
        { "data": "engine" },
        { "data": "browser" },
        {
          "data": "platform",
          "render": "[, ].name"
        }
      ]
    } );
    

    作为一个函数:

    $('#example').dataTable( {
      "columnDefs": [ {
        "targets": 0,
        "data": "download_link",
        "render": function ( data, type, full, meta ) {
          return '<a href="'+data+'">Download</a>';
        }
      } ]
    } );
    

    来自@VivienPipo 下面的补充:

    "render": function (data, type, full, meta) { 
        if (type == "display") { 
            return format_text_function(data); 
        } 
        return data; 
    }
    

    【讨论】:

      猜你喜欢
      • 2014-01-09
      • 1970-01-01
      • 2019-03-31
      • 1970-01-01
      • 2015-10-06
      • 2021-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多