【问题标题】:in front-end how set attribute or add class in td yajra dataTable在前端如何在 td yajra dataTable 中设置属性或添加类
【发布时间】:2021-05-11 08:06:08
【问题描述】:

如何在使用 [yajra] (https://github.com/yajra/laravel-datatables) 数据表时为列中的每个 td 添加 class_list 或设置属性

【问题讨论】:

    标签: yajra-datatable


    【解决方案1】:

    您在 javascript 中执行此操作。我有一个 css id 为“claims-table”的数据表。我想将类添加到第一列,在我的例子中称为“id”。我的代码如下。查看“列”以了解我正在添加类并将列作为 href 返回。

        $(function() {
            $('#claims-table').DataTable({
                processing: true,
                serverSide: true,
                searching: false,
                ajax: '/claims-table',
                columns: [
                    {data: 'id', name: 'id', render: function(data,type,row) {
                        data = '<a class="claim_info underline_td" claim_id="'+data+'" href="/#">Claim ID '+data+'</a>';
                        return data;
                    }},
                    {data: 'order_id', name: 'order_id'},
                    {data: 'name', name: 'name'},
                    {data: 'status_description',name: 'status_description'}
                ]
            });
        });
    

    【讨论】:

      猜你喜欢
      • 2016-02-06
      • 2017-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多