Update deeply nested data via fnUpdate
Update deeply nested data via fnUpdate
Hi there,
while datables supports deeply nested since version 1.8, updating nested/complex data via fnUpdate seems not to be possible.
A call like this ...
[code]fnUpdate({duration: 324, definition: 'hd'}, 5, 3, false, false})[/code]
... results in a warning in 1.8.0 and even in an error/exception when tried with 1.9.x ...
That is because fnUpdate always assumes that the user wants to update a whole row when first argument is a object. This should be easy to fix by not assume a complete row update when column number is given.
To me, updating the current state/data in a datatable instance is a key feature to prevent reloading the whole table after data has been sent to the server.
Any opinions on this one? :-)
Cheers,
Sascha
while datables supports deeply nested since version 1.8, updating nested/complex data via fnUpdate seems not to be possible.
A call like this ...
[code]fnUpdate({duration: 324, definition: 'hd'}, 5, 3, false, false})[/code]
... results in a warning in 1.8.0 and even in an error/exception when tried with 1.9.x ...
That is because fnUpdate always assumes that the user wants to update a whole row when first argument is a object. This should be easy to fix by not assume a complete row update when column number is given.
To me, updating the current state/data in a datatable instance is a key feature to prevent reloading the whole table after data has been sent to the server.
Any opinions on this one? :-)
Cheers,
Sascha
This discussion has been closed.
Replies
Excellent point thanks for flagging this up. I think this does need to be fixed, and I was just writing a unit test for it when I realised that this could be fairly complicated - the fix itself I think is easy enough, but I'm interested in the use case, since there could be a whole host of repercussions.
Specifically how are you getting the data back out for the column? Are you using mDataProp as a function? If you are using mDataProp as something like "3.duration" and "3.definition" for two different columns, then currently, DataTables will expect you to update the two columns separately. If you are using fnRender then one of the columns isn't going to have its rendering function called, since you are only attempting to update one column. The only way I can see what you have got working is if you are using mDataProp as a function...
Allan
The latest version is available on github or the download page :-)
Allan