Update deeply nested data via fnUpdate

Update deeply nested data via fnUpdate

morthahnamorthahna Posts: 18Questions: 0Answers: 0
edited June 2012 in General
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

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Hi Sascha,

    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
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    I've just committed a change to DataTables for this - I think this mDataProp as a function is the only way this would fully work, but it does allow some of the code to be tidied up and I think it is the correct thing to do.

    The latest version is available on github or the download page :-)

    Allan
This discussion has been closed.