Class inside render function for column in datatable

Class inside render function for column in datatable

omerabbasi78omerabbasi78 Posts: 17Questions: 7Answers: 1
edited September 2017 in Free community support

Consider following

var table = $("#tbl").DataTable({
        ajax: "/api/xyz/2",
        columns: [
            {
                data: 'abc',
                render: function (data, type, row, meta) {
                    if (parseInt(meta.row) == 0 || parseInt(meta.row) == 1) {
                        //Is it possible to apply Class here to column?
                    }
                    return "" ;
                },
            }],
      });
});

This question has an accepted answers - jump to answer

Answers

  • omerabbasi78omerabbasi78 Posts: 17Questions: 7Answers: 1

    did it like following

     columnDefs: [{
                targets: 2,
                createdCell: function (td, cellData, rowData, row, col) {
                    if (row <= 3) {
                        $(td).addClass('readonly');
                    }
                }
            }]
    

    but i would like to enhance my question... how can I disable keys on the same cells on which I've applied class??

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    By "keys" do you mean KeyTable? Currently there isn't a way to do that on a cell by cell basis. You can do it on a column basis using keys.columns.

    Allan

This discussion has been closed.