Closed AndOne1974 closed 3 months ago
Hi - thanks for this!
rows(.selected").remove().draw().
If you are using server-side processing, you wouldn't typically use rows().remove()
since that is a client-side action. It has no effect on the server-side data.
Are you able to give me a link to a page showing the issue please?
Well i call it on the client side to remove the row immediately and afterwards i do an ajax call to remove the record in the db.
btw the remove() set the record in hashmap to null but the draw() failed with an exception. It has nothing to do with the serverside, it is simply a client side issue if the column is not visible. You cannot check for prop if a[ order[i] ] is undefined.
Can you give me a link to a test case showing the issue so I can add it to the unit tests please? There is something more going on than just a cell in a hidden column and a row being removed, as that works fine as shown here: https://live.datatables.net/xixawalo/1/edit .
Oops - didn't mean to close this before. pressed the wrong button!
https://live.datatables.net/xixawalo/2/edit
here is the working example of the error:
dataTables.js:8188
Uncaught TypeError: Cannot read properties of null (reading '_detailsShow')
at _Api.
@AllanJard do you need more info about the error?
Thank you for the example! Based on that, here is a way to reproduce it without the extensions: https://live.datatables.net/nisokizi/23/edit .
I think it is this block that is the error rather than the pluck
function. I'll write a test and check it out.
I've committed this fix for that. I think the server-side processing "optimisation" could actually lead to a whole load of similar bugs. Per the comment there, I don't really expect client-side operations like this when using server-side processing, but it removes code to fix it, so that seems good to me :)
Thx @AllanJard !
https://github.com/DataTables/DataTablesSrc/blame/0e78039c4ae0e473be363a87ceecce74b0d4673c/js/core/core.internal.js#L159
If a[ order[i] ] is null than an exception is thrown. This can happen if serverSide rendering = true, the column is invisible and the row got removed by rows(.selected").remove().draw().
fix:
if ( a[ order[i] ] && a[ order[i] ][ prop ] ) { out.push( a[ order[i] ][ prop ][ prop2 ] ); }
should be the same if() as in _pluck