Editor field formatters not working for multirow editing with multiple values

Editor field formatters not working for multirow editing with multiple values

maxmediamaxmedia Posts: 6Questions: 3Answers: 0

Link to test case: https://live.datatables.net/poqihuxu/2/
Error messages shown: depends on situation, edited value is formatted wrong way, e.g. server data-type check can fail
Description of problem: we use setFormatter/getFormatter in Editor field definition to convert hours value stored as decimal (visible in datatable) to hh:mm string format for user editing. Works as expected for single row editing, or multi row editing where "hour" values are the same, or have the same values. But if you select two rows with different "hour" values and then edit "name" field, getFormatter is not called upon update and for each field string value is written back to datatable (or server database in real use case), breaking data model. (check console output)
Is there a way to handle this?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    Answer ✓

    That's a good one - thanks for brining this up. It is an error in how field().multiGet() works (i.e. column values). Internally what it is doing is getting the value from field().val() if it is a single row edit. But if it is a multi-row edit, it just takes the value from the data, and doesn't pass it through the formatter.

    The set option doesn't have that issue, as it will use the set formatter for multi-row editing. Unfortunately, that means we get the error you are seeing.

    I've committed a fix for this which will be in the next release of Editor. If urgent I can send you a the dev version with the fix? Without the fix, the only way to address this would be to do the get / set formatting at the server-side.

    Allan

  • maxmediamaxmedia Posts: 6Questions: 3Answers: 0

    Hello Allan, thanks for solving this. It's not urgent, however if you want me to test the patch on live project, please send me a dev version. Best regards, Juraj

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin

    Hi Juraj,

    Many thanks. It shouldn't be too long until the next Editor release - I'm working on various things for 2.4 at the moment, so probably easiest to just use the release if that is okay with you.

    Allan

Sign In or Register to comment.