Want fnRender to run after changing a value
Want fnRender to run after changing a value
I'm using datatables 1.9; my data is via an ajax source, so all the data ends up being on the client side. I'm using fnRender to display a true/false value as a checkbox, and I wrap that in a div with a class to indicate whether a change was made from the initial value (to highlight the changed cell). I'm using a hidden column to track the initial value of the data, and so my fnRender adds the appropriate class after comparing values.
After saving any changed values, I want to clear that changed state ... which means changing the value in the hidden column. The issue becomes how to get fnRender to fire for the visible column? It's value has only changed implicitly (just the rendering; the underlying value via fnGetData(row, column) will not indicate a change).
RIght now, I have a rather hacky fix, doing an:
oTable.fnUpdate( data[row][column], row, column+1); // set changed column to same as data
oTable.fnUpdate( data[row][column], row, column); // to dirty the cell
This does force the fnRender to fire for the visible column, but ... not ideal.
Thoughts?
john
After saving any changed values, I want to clear that changed state ... which means changing the value in the hidden column. The issue becomes how to get fnRender to fire for the visible column? It's value has only changed implicitly (just the rendering; the underlying value via fnGetData(row, column) will not indicate a change).
RIght now, I have a rather hacky fix, doing an:
oTable.fnUpdate( data[row][column], row, column+1); // set changed column to same as data
oTable.fnUpdate( data[row][column], row, column); // to dirty the cell
This does force the fnRender to fire for the visible column, but ... not ideal.
Thoughts?
john
This discussion has been closed.
Replies
One thing to watch with your current method is that it incurs two draws of the table - fine if its a small table, might be a problem if it is a bigger table or server-side processing. fnUpdate as a 'no redraw' option (fourth parameter I think).
Regards,
Allan
Might be interesting to do this as a plugin; we'll have to see if this is the only place I run into this.
Many thanks!
john