More Samples
Download Wijmo

CollectionView Editing

The CollectionView provides support for editing items with methods similar to those found in .NET's IEditableCollectionView interface: editItem, commitEdit, and cancelEdit.

The editItem method saves a copy of the item and puts the collection in 'edit mode'. While in edit mode, the view is not refreshed, so items will not be sorted or filtered out of view during the edit process.

The commitEdit method exits edit mode so sorting and filtering become active again. If the item has changed, the collectionChanged event fires so bound controls can show the changes.

The cancelEdit method restores the original data and exits edit mode.

You can see how this works by editing the grid below. When editing starts, a pencil icon appears on the row header to indicate the collection is in edit mode.

If you press the Escape key while in edit mode, the edits will be canceled and the original data will be restored.

If you move the selection to a different row, or move the focus away from the grid, the edits will be committed. At this point, the collection will refresh and any active filtering/sorting will be applied using the new item values.