Skip to content

Commit 4337e02

Browse files
dimodiDimo Dimovntacheva
authored
docs: Document new Grid/TreeList CUD event firing (#589)
* docs: Document new Grid/TreeList CUD event firing * Update components/grid/editing/incell.md Co-authored-by: Nadezhda Tacheva <[email protected]> * Update components/treelist/editing/incell.md Co-authored-by: Nadezhda Tacheva <[email protected]> * Remove commented part Co-authored-by: Dimo Dimov <[email protected]> Co-authored-by: Nadezhda Tacheva <[email protected]>
1 parent bad0d13 commit 4337e02

File tree

2 files changed

+51
-75
lines changed

2 files changed

+51
-75
lines changed

components/grid/editing/incell.md

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,32 @@ position: 4
1010

1111
# Grid InCell Editing
1212

13-
In Cell editing allows the user to click the cell and type the new value. When they remove focus from the grid or current row, the `OnUpdate` event fires, where the data-access logic can move it to the actual data source.
13+
In Cell editing allows the user to click cells and type new values immediately like in Excel. There is no need for Edit, Update and Cancel buttons.
1414

15-
You can also use the `Tab`, `Shift+Tab` and `Enter` keys to move between edited cells quickly to perform fast data updates. This lets the user edit efficiently, with few actions, like in Excel, while avoiding delays and re-renders from data updates that will break up that flow. Command columns and non-editable columns are not part from this keyboard navigation.
15+
Users can use the `Tab`, `Shift+Tab` and `Enter` keys to move between edited cells quickly. If validation is not satisfied, the user cannot exit edit mode, unless they satisfy validation, or cancel changes by pressing `Esc`.
16+
17+
Command columns and non-editable columns are skipped while tabbing.
18+
19+
The InCell edit mode provides a specific user experience and behaves differently than other edit modes. Please review the notes below to get a better understanding of these specifics.
1620

17-
When validation is not satisfied, you cannot close the cell (exit its edit mode), but you can cancel changes by pressing `Esc`.
1821

1922
#### Sections in this article
2023

2124
* [Basics](#basics)
22-
* [Notes](#notes)
25+
* [Event Sequence](#event-sequence)
26+
* [Incell Editing and Selection](#incell-editing-and-selection)
27+
* [Editor Template](#editor-template)
28+
2329

2430
## Basics
2531

2632
To enable InCell editing mode, set the `EditMode` property of the grid to `Telerik.Blazor.GridEditMode.Incell`. You can handle the `OnUpdate`, `OnCreate` and `OnDelete` events to perform the CUD operations, as shown in the example below.
2733

28-
To add a new item, you must add a [toolbar]({%slug components/grid/features/toolbar%}) with an `Add` command. `OnCreate` will fire immediately when you click the `Add` button, see the [Notes](#notes) below.
29-
30-
The `OnUpdate` event always fires for the last edited cell on the row - when you remove focus from the grid, or when you press `Enter` to go to the next row.
34+
To add a new item, you must add a [toolbar]({%slug components/grid/features/toolbar%}) with an `Add` command. `OnCreate` will fire immediately when you click the `Add` button - see [Event Sequence](#event-sequence) below.
3135

36+
It is up to the data access logic to save the data once it is changed in the data collection. The example below showcases when that happens and adds some code to provide a visual indication of the change. In a real application, the code for handling data updates may be entirely different.
3237

33-
>caption Reduced need for command buttons and user actions. The grid events let you handle data operations in InCell edit mode (see the code comments for details)
38+
>caption Incell Editing Example. See the code comments for details.
3439
3540
````CSHTML
3641
@using System.ComponentModel.DataAnnotations @* for the validation attributes *@
@@ -187,44 +192,29 @@ Click a cell, edit it and click outside of the grid to see the change. You can a
187192
![](images/incell-editing.gif)
188193

189194

195+
## Event Sequence
190196

191-
## Notes
192-
193-
The InCell edit mode provides a specific user experience that aims at fast efficient data entry. This requires that it behaves a differently than other edit modes. Please review the notes below to get a better understanding of these specifics:
194-
195-
196-
* [General](#general)
197-
* [Events Sequence](#events-sequence)
198-
* [Editor Template](#editor-template)
199-
200-
### General
201-
202-
* When the InCell Edit Mode is enabled and you want to enable item selection a `<GridCheckboxColumn />` must be added to the `<Columns>` collection. More information on that can be read in the [Selection]({%slug components/grid/selection/overview%}#notes) article.
203-
204-
* To see how to select the row that is being edited in InCell edit mode without using a `<GridCheckboxColumn />` check out the [Row Selection in Edit with InCell EditMode]({%slug grid-kb-row-select-incell-edit%}) Knowledge Base article.
205-
206-
* It is up to the data access logic to save the data once it is changed in the data collection. The example above showcases when that happens and adds some code to provide a visual indication of the change. In a real application, the code for handling data updates may be entirely different.
197+
* The `OnCreate` event will fire as soon as you click the `Add` button. The Grid will render the new row and enter edit mode for the first editable column (to fire `OnEdit` and let the user alter the column). This means you should have [default values]({%slug grid-kb-default-value-for-new-row%}) that satisfy any initial validation and requirements your models may have.
207198

208-
* If validation is not satisfied, you cannot open another cell for editing, and you need to either satisfy the validation, or press `Esc` to revert its value to the original one that should, ideally, satisfy validation.
199+
* This means that there is no actual inserted item, an item in InCell editing is always in Edit mode, never in Insert mode. Thus, you cannot use the `InsertedItem` field of the Grid [State]({%slug grid-state%}). If you want to insert items programmatically in the Grid, alter the `Data` collection, and use the `OriginalEditItem` feature of the state (see the [Initiate Editing or Inserting of an Item]({%slug grid-state%}#initiate-editing-or-inserting-of-an-item) example - it can put the InLine and PopUp edit modes in Insert mode, but this cannot work for InCell editing).
209200

201+
* The `OnEdit` event fires every time a cell is opened for editing. Until version **2.27**, the event fired **once per row** - when the user edits a cell from a different row.
210202

211-
### Events Sequence
203+
* The `OnUpdate` event fires every time an edited cell is closed. Until version **2.27**, the event fired **once per row** - when the currently edited row loses focus.
212204

213-
* The `OnCreate` event will fire as soon as you click the `Add` button so you can add the new row to the grid `Data` - this will let it show up in the grid, and then enter edit mode for the first editable column (to fire `OnEdit` and let the user alter the column). This means you should have [default values]({%slug grid-kb-default-value-for-new-row%}) that satisfy any initial validation and requirements your models may have.
205+
* If there is a cell that is being edited at the moment, clicking on another cell will first close the current cell and fire `OnUpdate`. To start editing the new cell, you need a second click. When the user removes focus from the Grid or the current row, the `OnUpdate` event fires, where the data-access logic can move it to the actual data source.
214206

215-
* This means that there is no actual inserted item, an item in InCell editing is always in Edit mode, never in Insert mode. Thus, you cannot use the `InsertedItem` field of the grid [State]({%slug grid-state%}). If you want to insert items programmatically in the grid, alter the `Data` collection, and use the `OriginalEditItem` feature of the state (see the [Initiate Editing or Inserting of an Item]({%slug grid-state%}#initiate-editing-or-inserting-of-an-item) example - it can put the InLine and PopUp edit modes in Insert mode, but this cannot work for InCell editing).
207+
* The `OnCancel` event works only when pressing `Esc`. The `Cancel` command button is not supported. Clicking outside the currently edited cell will trigger `OnUpdate` and thus, clicking on the `Cancel` command button will not fire the `OnCancel` event, because an update has already occured.
216208

217-
* The `OnEdit` event fires once per row - when the first cell from a row is opened for editing. Moving with the keyboard (`Tab` or `Shift+Tab`) between its cells does not fire events so that the grid does not re-render, and there is no lag for the user, especially from slow data operations such as `OnUpdate`. This caters to the user experience so they can input data quickly and efficiently.
218209

219-
* If you use the keyboard to navigate between open cells, `OnUpdate` will fire only when the entire row loses focus, not for each cell, so you will not need additional actions to open a new cell.
210+
## Incell Editing and Selection
220211

221-
* If there is a cell that is being edited at the moment, clicking on a cell will first close the current cell and fire `OnUpdate`. To start editing the new cell in such a case you will need a second click.
222-
223-
* The `OnCancel` event can work only with the keyboard (when you press `Esc`). The `Cancel` command button is not supported. Clicking outside the currently edited cell will trigger the `OnUpdate` event and thus, clicking on the `Cancel` command button will not fire the `OnCancel` event because an update has already occured.
212+
* To enable item selection with InCell Edit Mode, add a `<GridCheckboxColumn />` to the `<Columns>` collection. More information on that can be read in the [Selection]({%slug components/grid/selection/overview%}#notes) article.
224213

214+
* To see how to select the row that is being edited in InCell edit mode without using a `<GridCheckboxColumn />` check out the [Row Selection in Edit with InCell EditMode]({%slug grid-kb-row-select-incell-edit%}) Knowledge Base article.
225215

226-
### Editor Template
227216

217+
## Editor Template
228218

229219
When using an [editor template]({%slug components/grid/features/templates%}#edit-template), the grid cannot know what the custom editor needs to do, what it contains, and when it needs to close the cell and update the data, because this is up to the editor. This has the following implications:
230220

@@ -287,8 +277,6 @@ When using an [editor template]({%slug components/grid/features/templates%}#edit
287277
}
288278
</EditorTemplate>
289279

290-
291-
292280

293281
## See Also
294282

0 commit comments

Comments
 (0)