Your search did not match any results.

Data Grid - Edit State Management

Our DataGrid component manages its edit state automatically. If your use case requires full control over the editing process, you can use the API members below to manage state manually.

Backend API

Component Properties

  • editing.editRowKey
    The key for the row being edited.

  • editing.editColumnName
    The name or data field of the column being edited.

  • editing.changes
    Pending row changes.

You can get and set these properties at runtime to access and change edit state. In this demo, the onOptionChanged function gets editRowKey and changes property values and displays them under the DataGrid.

Utility Method

Event Handlers

  • onSaving / onSaved
    Functions that are called before / after pending row changes are saved via the UI or programmatically.

  • onEditCanceling / onEditCanceled
    Functions that are called before / after editing is canceled and pending row changes are discarded.

Use these functions to perform custom actions. In this demo, the onSaving function sends pending changes to a server. The function's parameter e contains fields for this capability. To implement the same in your application, follow these steps:

  1. Disable built-in edit state management
    Set the e.cancel field to true.

  2. Send a request to the server
    Pending changes are stored in the e.changes array. This array has only a single element in all edit modes, except for batch. Check if this element is not empty and send it to the server.

  3. Apply the same changes to a local array
    If the server successfully saves changes, call the applyChanges method to save the same changes in a local array.

  4. Update the DataGrid's data source and reset edit state
    Assign the local array to the dataSource, null to the editRowKey, and an empty array to the changes property.