Looking for example to redraw edited row after submission
Looking for example to redraw edited row after submission

I have a datatable whose source is MS Sql table via PHP. If a record has a column 'Inactive' = 1, then I apply a class in createdRow:
createdRow: function (row, data, dataIndex) {
if ( data.view_Addresses.Ignore == 1) {
$(row).addClass('strikethrough-row');
console.log('ignore dataIndex',dataIndex);
}
}
This works however after I edit, if the actions of the edit was setting Ignore it doesn't refresh the row (apply the strikethrough class). I need to manually refresh the datatable.
This question has an accepted answers - jump to answer
Answers
Have you tried
Please use Markdown to format your code!
I can add a little more information here.
createdRow
will trigger once and once only (when the row is created), so it isn't all that useful for data which might update (either via Editor or by something else).Instead, in this case use
rowCallback
- this is triggered whenever the row is drawn in the table. As a result it can be called when there is no update (i.e. just searching or paging the table), but it will be called on a draw from an update.So:
should do the job. Note that I've used
toggleClass
since your edit could also remove the strike-through condition (I presume).Allan
Thank you for the extra tip. I modified the rowCallBack to test for needing to change both ways: