Class inside render function for column in datatable

Class inside render function for column in datatable

omerabbasi78omerabbasi78 Posts: 17Questions: 7Answers: 1
edited September 14 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: 42,174Questions: 1Answers: 5,358 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

Sign In or Register to comment.