'in front-end how set attribute or add class in td yajra dataTable

how can I add class_list or set attribute for every td in column when using [yajra ] (https://github.com/yajra/laravel-datatables) datatable



Solution 1:[1]

You do it in the javascript. I have a datatable with the css id of "claims-table". I want to add classes to the first column, which in my case is called "id". My code is below. Look at the "columns" to see that I'm adding classes and returning the column as an 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'}
            ]
        });
    });

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1