When the DikeGrid is in the edition mode, it shows an icon (three vertical dots) at the left of every row. When you click on this icon, it will show a contextual menu with the edition operations per row.
At the same time, the DikeGrid shows an icon (three horizontal dots) in the header at the left of the first visible column header. When you click on this icon, it will show a contextual menu with the edition operations for multiple rows.
Editing rows
Let us start editing some rows by double-clicking on them. This action will display the edition templates for each editable column.
The DikeGrid allows you to have up to 10 rows in edition state by default, but you can change this value by providing the corresponding value.
You can change the maximum rows in the edition state value by providing an Injection Token or at the grid level.
When you reach the maximum number of rows in the edition state, the DikeGrid will show you a message indicating it.
Saving rows
Once you have made some changes to some rows, you can save these rows by clicking on the Save option from the contextual menu in the header.
Be aware that the DikeGrid will enable the Save option if all rows in the edition state are valid and at least one is not pristine. Therefore, the DikeGrid will save those valid rows which are not pristine.
After updating rows, the DikeGrid changes the status of every row to the Modified value.
Please, open the live example to test the Save operation.
Canceling edition
When you have some rows in the edition state, the first enabled option in the contextual menu is Cancel.
Clicking on the Cancel option in the context menu will cancel the edition of all the rows in the edition state.
If you have made some changes, you will lose those changes by canceling the edition.
Deleting rows
To delete rows from the DikeGrid UI, you must enable the selection operation. Therefore, you can delete only the selected rows from the UI.
The Remove option appears in the contextual menu if you allow the user to select rows, and the DikeGrid will enable it only when the user has selected one row at least.
Let us provide the corresponding input property to enable the selection operation.
If the user has selected rows in the edition state, the DikeGrid will not delete them.
Reverting changes
You can undo changes from the modified or deleted rows. Therefore, you have to change the view from the UI to display only modified or deleted rows.
Edition filters
If you open the context menu, you can see an option called Edition Filter, and under this option, you will find the edition subsets options.
The DikeGrid will take the user to the edition view by clicking on these edition subsets options.
Option - Editing
Clicking on this menu option will display only the rows in the edition state. Showing only the rows editing is helpful when you have grouped the rows, for instance, because the rows in the edition state could be in different groups.
As you can see, the icon in the header changes to a pencil icon (instead of the three horizontal dots), indicating that you are viewing only the rows in the edition state.
Option - Modified
This menu option shows only those rows that have suffered changes. When you navigate to the modified-rows view, you will see an icon with a badge at the left of every row. The badge indicates how many times the user has changed the row.
You click on the icon with a badge to revert the changes in the row. This action will take the row to its immediate previous state.
You can click on the icon with a badge until the row reaches its initial state. The initial state corresponds to the row state equals to Read value.
If you have enabled the selection operation, you can select more than one row and take them to their immediate previous state by clicking on the Restore option from the contextual menu.
Once again, see how the DikeGrid changes the icon to indicate that you are viewing the modified rows.
Option - Removed
This menu option shows only the subset of rows that corresponds to the deleted rows. When you are in the deleted-rows view, you will see an icon with a badge at the left of every row. Again, the badge indicates how many times the user has changed the row, but this time the last action corresponds to the deletion operation.
If the badge displays a number greater than one means that the row has suffered changes before deleting it.
The DikeGrid changes the icon in the header to indicate that you are viewing the deleted rows.
If you have enabled the selection operation, you can select more than one row and restore them by clicking on the Restore option from the contextual menu.
Option - Back
You can display the standard view by clicking on the Back option.
You can filter every edition subset of rows by typing values in a filterable column. The values you enter in the Edition Filters view are independent of the values in the standard view.
Edition Toolbar
All the edition actions for multiple rows are available through the Edition Toolbar. When you display the Edition Toolbar, the DikeGrid hides the contextual menu in the header.
If you want to use the Edition Toolbar in the live example, open the Floating Configuration Panel and click on the Edition Toolbar checkbox.
When displaying the Edition Toolbar, the DikeGrid still shows the icon in the header but does not show the contextual menu.
Customizing the Edition Toolbar
You can change the appearance of the Edition Toolbar by modifying its height, alignment, or position. You can also change the size of its items.
The previous definition generates the following output:
We have added the following buttons:
Save rows. This action updates the rows in edition state. Remember that the DikeGrid will save only those valid rows that are not pristine.
Cancel Edition. Clicking on this button will cancel the edition state for every row editing.
Remove rows. Click on this button to delete the selected rows. The DikeGrid will not remove the rows in the edition state.
Restore rows. This action works over the modified or deleted rows. Therefore, you select which type of rows the DikeGrid will restore.
Edition events
The edition events for multiple rows are the same when working over one row. Regarding the various rows edition, the DikeGrid emits an array of rows instead of one row.
Apart from saving changes for one row, you can update multiples rows simultaneously. However, be aware that you must enable the selection operation for deleting and restoring multiple rows.
You must navigate to the edition view for restoring rows by clicking on the corresponding edition filter. Every row shows an icon with a badge conveying how many times the row has suffered changes.
You can perform the edition actions for multiple rows using the edition API. Moreover, the DikeGrid emits the related event for every edition action.
This value affects all your DikeGrid instances that live under the place you give your Injection Token.
DikeGridEditionSettings { maxRowsInEdition?: number };
Providing at this level only affects the DikeGrid instance that receives the value.
updateRowsInEdition()
This method takes all valid rows which are not pristine and saves their changes.
removeRows()
It removes from the given rows only those rows that are not in the edition state and do not have the Deleted value in their row status.
cancelRowsInEdition()
It cancels the current edition state for every row, losing all the changes you have made.
restoreRows()
It takes the given rows to their immediate previous row state. It filters the given rows taking only those modified or deleted rows.
setEditionFilter()
It displays the corresponding subset of rows editing. Invoking this method is equivalent to clicking on the contextual menu's Editing, Modified, or Removed options.
Since this method changes the view of the DikeGrid, you should have provided the allowEdition and editionMode input properties.
cancelEditionFilter()
Invoking this method, the DikeGrid will show the standard view. It is equivalent to clicking on the Back option of the contextual menu.