How to run rowCallback in a function within a button?

How to run rowCallback in a function within a button?

BigDataWarehouseBigDataWarehouse Posts: 23Questions: 10Answers: 0

I have some conditional formatting in my

rowCallback: function(row, data, index) {....}

I also have an additional button:

{
text: 'Click Here',
action: function ( e, dt, node, config ) {
table.draw(); <--- this only redraws the table and never run rowCallback
//rowCallback.
}
}

I need the table to refresh and rowCallback to run its conditional formatting

Many Thanks!

Answers

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    I'm sure rowCallback is running but you could put a console.log() statement in the function to verify. Sounds like you are updating the table data and expecting the formatting to change? If you are updating the DOM directly then Datatables won't know about the change and won't update its data cache so the formatting doesn't change. You need to either update the table using Datatables APIs like row().data() or cell().data or use -row().invalidate() or cell().invalidate() to have Datatables update its cache.

    Please post more information about what you are doing. A link to your page or test case would be best.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

This discussion has been closed.