Dynamically updating a field

Dynamically updating a field

nlooijenlooije Posts: 44Questions: 8Answers: 0

I am trying to dynamically update a field (datatable type) upon editing a row:

    editor.on('initEdit', function(e, row, data, items, type){
        this.field('problem_descriptions[].text').update(data.problem_descriptions);
        //this.field('problem_descriptions[].text').update(data.problem_descriptions, false);
    })

This however seems to append everytime a row is opened for editing.
The first time opening a row shows the data correctly:

but closing the row edit and opening another for editing:

shows that the current data is appended to the previous data.

According to the manual, a second argument can be provided to have the data appended or not and it is by default set to false. But even explicitely setting it to false (as in the code above) results in appending behaviour.

Is this a bug or am i misunderstanding the way update is used?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    edited July 2021 Answer ✓

    I'm not seeing that here - I'm using a select. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Cheers,

    Colin

  • nlooijenlooije Posts: 44Questions: 8Answers: 0

    Thank you for the test case; that is how i expect it to work

    Some observations:
    1. If i use a datatable field type, the problem is there.
    2. If i convert my case to a select field type, there is no issue
    3. If i convert your case to a datatable field type, there is also no issue

    Strange, but it definetly is something in my code...

  • nlooijenlooije Posts: 44Questions: 8Answers: 0
    edited July 2021

    4 If i copy your test case to my page, the problem is also there

    It turns out it is a bug in the version of Editor i am using.
    After upgrading to the latest version this problem disappears.

    Thanks for the help @colin

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Excellent, thanks for letting us know,

    Colin

Sign In or Register to comment.