You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added documentation for Row click and double click events (#87)
* chore(grid): Updated events article to contain row click and double click events
* chore(grid): updates on the events article to contain row click and double click events
* chore(grid): row click events minor improvements
* chore(grid): restored pagechanged event documentation
* chore(grid): updates on the events article
* chore(grid); added load on demand example for the RowClickEvent
* chore(grid): updated selection overview article to include that async operations should be handled in the row click events
* chore(grid): minor improvements on row click event
Co-authored-by: Marin Bratanov <[email protected]>
Copy file name to clipboardExpand all lines: components/grid/events.md
+149Lines changed: 149 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,8 @@ This article explains the events available in the Telerik Grid for Blazor. They
17
17
*[Other Events](#other-events) - other events the grid provides
18
18
* [Command Button Click](#command-button-click)
19
19
* [SelectedItemsChanged](#selecteditemschanged)
20
+
* [OnRowClick](#onrowclick)
21
+
* [OnRowDoubleClick](#onrowdoubleclick)
20
22
* [PageChanged](#pagechanged)
21
23
22
24
## CUD Events
@@ -42,6 +44,153 @@ The command buttons of a grid provide an `OnClick` event before firing their bui
42
44
43
45
Fires when the item selection is enabled and the user changes the selected [item]({%slug components/grid/selection/single%}#selecteditemschanged-event) or [items]({%slug components/grid/selection/multiple%}#selecteditemschanged-event).
44
46
47
+
### OnRowClick
48
+
49
+
The `OnRowClick` event fires as a response to the user clicking on a row of the Grid. Clicking on the `GridCommandButton`, select row `CheckBox`, expanding a `Detail Template` or when the row is in `edit/insert mode` will not trigger the event.
50
+
51
+
The event handler receives a `GridRowClickEventArgs` object which provides the model of the clicked row in the `Item` field that you can cast to your model type.
52
+
53
+
>caption Use the OnRowClick event to load data on demand based on the clicked row
54
+
55
+
````CSHTML
56
+
@* Use the OnRowClick event to load data on demand based on the clicked row *@
The `OnRowDoubleClick` event fires as a response to the user double clicking on a row of the Grid. Clicking on the `GridCommandButton`, select row `CheckBox`, expanding a `Detail Template` or when the row is in `edit/insert mode` will not trigger the event.
137
+
138
+
The event handler receives a `GridRowClickEventArgs` object which provides the model of the clicked row in the `Item` field that you can cast to your model type
139
+
140
+
>caption Use the OnRowDoubleClick event to receive information on the clicked row
141
+
142
+
````CSHTML
143
+
144
+
@* Use the OnRowDoubleClick event to receive information on the row the user clicked on *@
@@ -119,6 +120,10 @@ When using the Grid [Template](https://docs.telerik.com/blazor-ui/components/gri
119
120
120
121
If you are using the [Row Template]({%slug components/grid/features/templates%}#row-template), the grid cannot render selection checkboxes for you, so you have to bind them yourself to a field in the model, and handle their selection changed event to populate the `SelectedItems` collection of the grid. You can find an example to get started in the following thread: [Grid Row Template with Selection - Unsure how to Bind to Selected Item](https://feedback.telerik.com/blazor/1463819-grid-row-template-with-selection-unsure-how-to-bind-to-selected-item)
121
122
123
+
### Asynchronous Operations
124
+
125
+
Asynchronous operations such as loading data on demand should be handled in the [`OnRowClick`]({%slug grid-events%}#onrowclick) or [`OnRowDoubleClick`]({%slug grid-events%}#onrowdoubleclick) events rather than in the [`SelectedItemsChanged`]({%slug grid-events%}#selecteditemschanged).
126
+
122
127
### Handle Data Changes
123
128
124
129
When the grid `Data` collection changes, the `SelectedItems` collection has the following behavior:
Copy file name to clipboardExpand all lines: components/grid/selection/single.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,8 @@ You can respond to the user action of selecting a new item through the `Selected
103
103
104
104
The example below shows how to handle the `SelectedItemsChanged` event to extract information about the selected item and use it to populate a second grid with details about the selected record.
105
105
106
+
>tip If you want to load that data on demand, you should use the [OnRowClick event]({%slug grid-events%}#onrowclick).
107
+
106
108
>caption Single Selection and handling the SelectedItemsChanged event
107
109
108
110
````CSHTML
@@ -145,6 +147,7 @@ The example below shows how to handle the `SelectedItemsChanged` event to extrac
145
147
SelectedItems = new List<Employee> { SelectedEmployee };
146
148
147
149
GetChildGridData(); // note: an async operation here can break the selection and may not even render its results in the view
0 commit comments