FlexGrid - TreeGrid ChildItems

Posted by: dev on 8 July 2021, 12:41 pm EST

    • Post Options:
    • Link

    Posted 8 July 2021, 12:41 pm EST

    Hi

    Is it possible to have a CollectionView as children in a TreeGrid? i.e. the childItemsPath refers to another CollectionView?

    What I’m trying to do is to track changes in child items so that I can use this information to update a database on clicking a save button. Currently the parent level CollectionView doesn’t appear to track child item changes / edits. Is there another way this can be achieved?

  • Posted 9 July 2021, 9:18 am EST

    I’m really interested to tee the response on this!

  • Posted 12 July 2021, 3:22 am EST

    Hi,

    We are sorry but it is not possible to have nested collectionView as source for the grid, to support change tracking we could handle the cellEditEnded event and add the changed item to the itemsEdited collection manually. Please refer to the following code snippet and the sample demonstrating the same:

    grid.cellEditEnded.addHandler((s, e) => {
        let oldValue = e.data;
        let newValue = s.getCellData(e.row, e.col);
    
        if (oldValue !== newValue) {
          markAsEdited(grid, e.getRow().dataItem);
        }
      });
    function markAsEdited(grid, item) {
      let existingItem = grid.collectionView.itemsEdited.find(
        (_item) => _item === item
      );
      if (!existingItem) {
        grid.collectionView.itemsEdited.push(item);
      }
    }
    

    https://codesandbox.io/s/wijmo-starter-forked-fhotd?file=/src/index.js

    Regards

    Sharad

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels