Inline Editor - after edit, change color of another cell

Inline Editor - after edit, change color of another cell

AaronsAarons Posts: 13Questions: 5Answers: 0

Using the inline editor, after making the edit, I want to change the color of a different cell if something was entered that needs to be called out.

For example, you inline edit a numeric field, and that value causes another field to go below 0. I want to highlight that other field.

I tried the following, but the field (index 10) doesn't actually change color.

     editor.on('postSubmit', function (e, json, data) {

            var modifier = editor.modifier();
            var currentRow = table.row(modifier);

            if (json.data[0]["MyCustomField1"] > json.data[0]["MyCustomField2"]) {
                $('td', currentRow).eq(10).css('color', 'Red');
            } else {
                $('td', currentRow).eq(10).css('color', 'Black');
            }
        });

Performing the same logic on CreatedRow on the table does work:

What am I missing?

This question has an accepted answers - jump to answer

Answers

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

    var currentRow = table.row(modifier);

    Should be:

    var currentRow = table.row(modifier).node();
    

    i.e. get the tr element for the selected row (using row().node()) and then use that in the selector for jQuery. At the moment your jQuery selector is getting a DataTables API instance passed into it.

    Regards,
    Allan

  • AaronsAarons Posts: 13Questions: 5Answers: 0

    That was it!

    Thank you very much for your help!

    (sory for the late reply)

This discussion has been closed.