Feature request: Allow successCallback data of ajax not to be merged with existing row data.

Feature request: Allow successCallback data of ajax not to be merged with existing row data.

Radoslav KonuchRadoslav Konuch Posts: 9Questions: 4Answers: 0

Hello, currently, if you have set drawType === 'none', you need to manually pass new or updated row data to successCallback as a result of ajax request to make the table row update itself with the new data. The passed row data is then internally merged with existing table row data, to fill in missing properties, in case just a sub-set of row fields was returned. However, in our business case, we also expect that some of the fields are missing intentionally in the returned set of data, and we render these columns in a specific way. However, editor fills in these missing fields with cached table row fields.
Here's a snippet from editor 1.9.2 starting at line #6956:

// Merge data to allow for a sub-set to be returned
var extender = $.fn.dataTableExt.oApi._fnExtend;
var toSave = extender( {}, row.data(), true );
toSave = extender( toSave, data, true );

row.data( toSave );

Could this behaviour be optionally disabled, so user can manually set, what data are passed back to datatable renderers after successful edit?
Proposal: Add a switch setting, for example allowSubsetResponse, which when set to false, would not automatically merge the data passed to successCallback with respective table row data.

Thanks for the response.
Rado

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,722Questions: 1Answers: 10,108 Site admin
    Answer ✓

    Hi Rado,

    Really interesting - thank you for posting this. Interestingly what you are asking for used to be the behaviour of Editor it a frequent request was to merge the data allowing partial returns.

    I've added a feature request bug to our tracker to get this added in. We'll try to get it in for the next patch release as its a minor change as you indicate.

    Allan

  • Radoslav KonuchRadoslav Konuch Posts: 9Questions: 4Answers: 0

    Thank you Allan :)

  • Radoslav KonuchRadoslav Konuch Posts: 9Questions: 4Answers: 0
    edited May 2020

    Hello Alan, I've seen you released version 1.9.3. Could not find this issue within the changelog though. Thanks. Rado

  • allanallan Posts: 61,722Questions: 1Answers: 10,108 Site admin

    Apologies, no - we didn't include this in 1.9.3 in the end. It is still in our feature tracker though, so it is still on our radar. Until then a small patch could be applied to the code to get the behaviour you are looking for.

    Allan

This discussion has been closed.