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
Copy file name to clipboardExpand all lines: components/grid/columns/command.md
+18-13Lines changed: 18 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -14,35 +14,37 @@ The command column of a grid allows you to initiate [inline]({%slug components/g
14
14
15
15
To define it, add a `TelerikGridCommandColumn` in the `TelerikGridColumns` collection of a grid. The command column takes a collection of `TelerikGridCommandButton` instances that invoke the commands. It also offers the `Title` property so you can set its header text.
16
16
17
-
>tip The lists below showcase the available features and their use, and after them you can find a code example that shows declarations and handling.
17
+
>tip The lists below showcase the available features and their use. After them you can find a code example that shows declarations and handling.
18
18
19
19
The `TelerikGridCommandButton` tag offers the following features:
20
20
21
-
*`Command` - the command that will be invoked. Can be one of the built-in commands, or a custom command name.
22
-
*`OnClick` - the event handler that the button will fire.
21
+
*`Command` - the command that will be invoked. Can be one of the built-in commands (see below), or a custom command name.
22
+
*`OnClick` - the event handler that the button will fire. If used on a built-in command, this handler will fire before the [corresponding CRUD event]({%slug components/grid/editing/overview%}). Cancelling it will prevent the built-in CRUD event from firing.
23
23
*`ShowInEdit` - a boolean property indicating whether the button is only visible while the user is editing/inserting data.
24
24
*`ChildContent` - the text the button will render. You can also place it between the command button's opening and closing tags.
25
-
* Appearance properties like Icon, Class, Enabled that are come from the underlying [Button Component features]({%slug components/button/overview%}).
25
+
* Appearance properties like `Icon`, `Class`, `Enabled` that are come from the underlying [Button Component features]({%slug components/button/overview%}).
26
26
27
27
There are three built-in commands:
28
28
29
29
*`Edit` - initiates the inline or popup editing (depending on the EditMode configuration of the grid).
30
-
*`Update` - performs the actual update operation after the data has been changed. Allows you to trigger an event handler to perform the data source operation.
30
+
*`Save` - performs the actual update operation after the data has been changed. Triggers the `OnUpdate` or `OnCreate` event so you can perform the data source operation. Which event is triggered depends on whether the item was added through the grid or not.
31
31
*`Cancel` - aborts the current operation (edit or insert).
32
32
33
33
The `OnClick` handler of the commands receives an argument of type `GridCommandEventArgs` that exposes the following properties:
34
34
35
35
*`IsCancelled` - set this to true to prevent the operation if the business logic requires it.
36
36
*`Item` - the model item the grid row is bound to. You can use it to access the model fields and methods in order to preform the actual data source operations.
37
-
*`Type` - the type of event (command).
37
+
*`IsNew` - a boolean field indicating whether the item was just added through the grid interface.
38
+
39
+
>tip For handling CRUD operations we recommend that you use the grid events (`OnEdit`, `OnUpdate`, `OnCancel`, `OnCreate`). The `OnClick` handler is available for the built-in commands to provide consistency of the API.
38
40
39
41
>caption Example of adding and handling command columns for inline editing of a grid
40
42
41
43
````CSHTML
42
44
@using Telerik.Blazor
43
45
@using Telerik.Blazor.Components.Grid
44
46
45
-
<span>Edit will cancelled for "name 2"</span>
47
+
<span>Edit will be cancelled for "name 2"</span>
46
48
<br />@CustomCommandResult
47
49
48
50
<TelerikGrid Data=@GridData EditMode="inline"
@@ -52,9 +54,9 @@ The `OnClick` handler of the commands receives an argument of type `GridCommandE
Copy file name to clipboardExpand all lines: components/grid/editing/incell.md
+27-5Lines changed: 27 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,9 @@ position: 4
10
10
11
11
# Grid InCell Editing
12
12
13
-
In Cell editing allows the user has to click the cell and type the new value. When they remove focus from the input, the new value is sent to the model, where the data-access logic can move it to the actual data source.
13
+
In Cell editing allows the user to click the cell and type the new value. When they remove focus from the input, the `OnUpdate` event fires, where the data-access logic can move it to the actual data source.
14
14
15
-
You can handle the `Update`and `Delete` events to perform the CRUD operations, as shown in the example below. At the moment, the in-cell editing does not support item creation or cancellation of changes.
15
+
You can handle the `OnUpdate`, `OnCreate`and `OnDelete` events to perform the CUD operations, as shown in the example below. To add a new item, you must also add a [command column]({%slug components/grid/columns/command%}) with a `Save` command and a [toolbar]({%slug components/grid/features/toolbar%}) with an `Add` command. Cancellation of changes is not supported at the moment, you can prevent them by not calling the data access layer.
16
16
17
17
To enable InCell editing mode, set the `EditMode` property of the grid to `incell`, then handle the CRUD events as shown in the example below.
18
18
@@ -25,10 +25,17 @@ To enable InCell editing mode, set the `EditMode` property of the grid to `incel
25
25
<strong>Click a cell, edit it and click outside of the cell to see the change. Editing is prevented for the first two items.</strong>
Copy file name to clipboardExpand all lines: components/grid/editing/inline.md
+12-10Lines changed: 12 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,11 @@ position: 1
10
10
11
11
# Grid Inline Editing
12
12
13
-
Inline editing lets the user click an [Edit command button]({%slug components/grid/columns/command%}) on the row, and all its editable columns open up for changes. They can then click an **Update** command button to submit the changes to the model. This fires the `OnUpdate` event of the grid where your code receives the updated model so you can work with the data (for example, to call the `SaveChanges()` method of your context).
13
+
Inline editing lets the user click an [Edit command button]({%slug components/grid/columns/command%}) on the row, and all its editable columns open up for changes. They can then click an `Save` command button to submit the changes to the data access layer. This fires the `OnUpdate` event of the grid where your code receives the updated model so you can work with the data (for example, to call the `SaveChanges()` method of your context).
14
14
15
-
In a similar fashion, the `Cancel`, `Delete` command buttons and the `Create` toolbar button fire events on the grid to let you handle the data source operations.
15
+
In a similar fashion, the `Cancel` and `Delete` command buttons fire events on the grid to let you handle the data source operations.
16
16
17
-
You can also cancel the evens by setting the `IsCancelled` property of the event arguments to `true`. This lets you prevent the user from editing certain records, inserting or deleting items, based on your application logic.
17
+
You can also cancel the events by setting the `IsCancelled` property of the event arguments to `true`. This lets you prevent the user from editing certain records, inserting or deleting items, based on your application logic.
18
18
19
19
To enable Inline editing in the grid, set its `EditMode` property to `inline`, then handle the CRUD events as shown in the example below.
20
20
@@ -31,13 +31,13 @@ To enable Inline editing in the grid, set its `EditMode` property to `inline`, t
0 commit comments