update css AFTER edit

update css AFTER edit

hbanaharishbanaharis Posts: 32Questions: 14Answers: 3

Supposing we have css defined in columnDefs where we highlight a number based on a value, eg

columnDefs: [{
      targets: '1',
      createdCell: function(td, cellData, rowData, row, col) {
        $(td).attr('title', cellData);
if ( cellData > 30 ) {
                    $(td).css('color', 'red');
                  }

How do we go about updating the css AFTER an edit to a cell?

Please provide an example

This question has an accepted answers - jump to answer

Answers

  • hbanaharishbanaharis Posts: 32Questions: 14Answers: 3
    Answer ✓

    The edited cell event can be accessed via

    editor.on('postEdit', function(e, json, data, id) { ...  }
    

    This enables the row which was edited to be accessed using jQuery via

    $('#' + data.DT_RowId+'')
    
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Spot on! Currently DataTables itself doesn't have an event or callback for updated data, but Editor's events can be used for that.

    Allan

This discussion has been closed.