TreeList new row disappears on edit

1 Answer 11 Views
TreeList
Daniel
Top achievements
Rank 1
Daniel asked on 18 Jun 2025, 03:04 PM

I have a TreeList control where the data is kept in an array in memory - the user will save manually after editing everything they need to.

One problem I'm facing is that if a new record is created, and then subsequently edited - it will disappear after either Save or Cancel.

I've removed a lot of the code for brevity - but this is a working example of what I have:

https://dojo.telerik.com/tDidtCqZ

Any idea what I'm doing wrong?

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 23 Jun 2025, 07:27 AM

Hello,

I've reviewed your shared Dojo example and the issue is related to how the TreeList DataSource handles new items when working with in-memory arrays and custom transport logic, especially when batch mode is enabled and data is not persisted immediately.

Why the New Row Disappears

  • When you create a new record and then edit it, the DataSource tracks the item as "new" (isNew()) and/or "dirty". In the current scenario, you have to manually ensure the new item is added to your in-memory array.

You need to make sure that:

  • Any new record is immediately added to your in-memory array (dsData) upon creation, not just when you call sync or save.
  • The DataSource and your in-memory array stay in sync, so the TreeList does not lose track of newly created items.

Example Fix for the create Transport

Update your create transport function so that every new model is pushed to your dsData array as soon as it is created:

create: function (options) {
    for (let i = 0; i < options.data.models.length; i++) {
        if (options.data.models[i]._x_Added) {
            continue;
        }
        maxId++;
        options.data.models[i]._x_Added = true;
        options.data.models[i]._x_ID = maxId;

        // Add the new item to the in-memory array
        dsData.push(options.data.models[i]);
    }
    options.success(options.data.models);
},

Here you will find the modified Dojo example - https://dojo.telerik.com/KtoYquAR.

I hope this helps. 

    Regards,
    Neli
    Progress Telerik

    Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

    Daniel
    Top achievements
    Rank 1
    commented on 23 Jun 2025, 02:38 PM

    Thank you so much Neli - it worked a treat
    Tags
    TreeList
    Asked by
    Daniel
    Top achievements
    Rank 1
    Answers by
    Neli
    Telerik team
    Share this question
    or