【问题标题】:How to add a class to the <td> in server-side processing mode如何在服务器端处理模式下向 <td> 添加一个类
【发布时间】:2015-08-12 21:55:26
【问题描述】:

在 DataTable 上使用服务器端处理时,有一种机制可以通过包含 DT_RowIdDT_RowClass 或 @ 将 ID、类或 data-* 属性添加到表行 (&lt;tr&gt;) 987654326@属性,分别对应每行的JSON数据:https://datatables.net/examples/server_side/ids.html

是否有类似(或任何)机制可以为表格列添加额外的标记 (&lt;td&gt;)?

【问题讨论】:

    标签: javascript html datatables


    【解决方案1】:

    您可以像这样向列添加类,但不确定这是否能让您到达您想去的地方:

         var all_data = data;
         $("#example").DataTable({
                "data": all_data,
          "aoColumns": [{
            "data": 'cat_code',
            "className": "lang_body_2",//you can add whatever you want for a specific column here.
            "visible": false
        }, {
            "data": 'value',
            "searchable": false,
            "width": "20%",
            "className": "lang_body_2",
            "title": ""
        }]
      })
    

    【讨论】:

    【解决方案2】:

    另一种方式,从关闭。网站docs。 将类 my_class 分配给第一列

    $('#example').dataTable( {
      "columnDefs": [
        { className: "my_class", "targets": [ 0 ] }
      ]
    } );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-18
      • 2019-06-10
      • 2015-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多