CollectionView: How to forcely trigger a row update event?

Posted by: james.ingham on 8 February 2021, 1:09 am EST

    • Post Options:
    • Link

    Posted 8 February 2021, 1:09 am EST

    Dear Support,

    We are listening to the itemEdited, itemAdded and itemRemoved events to determine whether a FlexGrid is dirty. However we are not quite sure under what situations the CollectionView may think the editing is finished. It looks like users have to press the “Enter” key, or click other rows to trigger an itemEdited event, but sometimes it’s not intuitive. For instance, in this example:

    https://stackblitz.com/edit/angular-zxnxen

    the Active column has Booelan type. If you click the checkbox, it doesn’t trigger itemEditted event until you press Enter or click other rows.

    The expected behavior should be:

    When user clicks any checkbox (boolean type), then the itemsEdited collectionView should be immediately updated.

    Is it feasible?

  • Posted 8 February 2021, 4:38 am EST

    Hi James,

    This is the default behavior. To improve performance itemsEdited() event is fired only when the row item is finished editing i.e when we change the selected row after editing.

    If you wish to change this behaviour and commit changes as soon as value is updated in the cell then you may handle the cellEditEnded event and call commitEdit() method of the collectionView. Please refer to the following code snippet and the sample demonstrating the same:

    grid.cellEditEnded.addHandler((s, e) => {
          if (s.editableCollectionView && s.editableCollectionView.editItem) {
            s.editableCollectionView.commitEdit();
          }
        });
    

    https://stackblitz.com/edit/angular-ehzeaf?file=src%2Fapp%2Fapp.component.ts

    ~sharad

  • Posted 11 February 2021, 1:13 am EST

    Thanks a lot! commitEdit() is the function to do the trick. It works!

Need extra support?

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

Learn More

Forum Channels