diff --git a/_contentTemplates/grid/editing.md b/_contentTemplates/grid/editing.md index af30c1c36c..4b670c6a99 100644 --- a/_contentTemplates/grid/editing.md +++ b/_contentTemplates/grid/editing.md @@ -14,7 +14,7 @@ Without using the above command buttons, the application can: #end #basic-example-description -* Use the `OnCreate`, `OnDelete` and `OnUpdate` events to make changes to the Grid data source. +* Use the `OnCreate`, `OnDelete` and `OnUpdate` events to make changes to the Grid data source. Item deletion relies on **Delete** command buttons and the `OnDelete` handler receives one data item in its event argument. [When using the `GridToolBarDeleteTool`](slug:components/grid/features/toolbar#toolbar-tools-configuration) with multiple [row selection](slug:grid-selection-row), the `OnDelete` handler may receive multiple data items for deletion. * Rebind the Grid automatically through the `OnRead` event after the create, delete, or update operation is complete. When [using the `Data` parameter, you must either query the data source again, or modify the local `Data` collection manually](#advanced). * Use `DataAnnotations` validation for some model class properties. #end @@ -39,14 +39,14 @@ Without using the above command buttons, the application can: private async Task OnGridCreate(GridCommandEventArgs args) { - var createdItem = (Product)args.Item; + var createdItem = (Product)args.Items.First(); await GridProductService.Create(createdItem); } private async Task OnGridDelete(GridCommandEventArgs args) { - var deletedItem = (Product)args.Item; + var deletedItem = (Product)args.Items.First(); await GridProductService.Delete(deletedItem); } @@ -62,7 +62,7 @@ Without using the above command buttons, the application can: private async Task OnGridUpdate(GridCommandEventArgs args) { - var updatedItem = (Product)args.Item; + var updatedItem = (Product)args.Items.First(); await GridProductService.Update(updatedItem); } @@ -170,7 +170,7 @@ Without using the above command buttons, the application can: #end #advanced-example-description -* Use the `OnCreate`, `OnDelete` and `OnUpdate` events to make changes to the Grid data source. +* Use the `OnCreate`, `OnDelete` and `OnUpdate` events to make changes to the Grid data source. Item deletion relies on **Delete** command buttons and the `OnDelete` handler receives one data item in its event argument. [When using the `GridToolBarDeleteTool`](slug:components/grid/features/toolbar#toolbar-tools-configuration) with multiple [row selection](slug:grid-selection-row), the `OnDelete` handler may receive multiple data items for deletion. * Use the `OnModelInit` event to provide [model instances](slug:grid-editing-overview#item-instances) with some default values before add and edit operations start. * Use the `OnAdd` event to provide some default values before add operations start. * Use the `NewRowPosition` parameter to set there new rows are added to the existing data. @@ -260,7 +260,7 @@ Without using the above command buttons, the application can: args.IsCancelled = true; } - var newItem = (Product)args.Item; + var newItem = (Product)args.Items.First(); newItem.Name = "Value from OnAdd"; } @@ -279,7 +279,7 @@ Without using the above command buttons, the application can: private async Task OnGridCreate(GridCommandEventArgs args) { - var createdItem = (Product)args.Item; + var createdItem = (Product)args.Items.First(); // Create the item in the database. int newItemIndex = GridNewRowPosition == GridNewRowPosition.Bottom ? Math.Min(GridPageSize * GridPage - 1, GridData.Count) : 0; @@ -295,7 +295,7 @@ Without using the above command buttons, the application can: private async Task OnGridDelete(GridCommandEventArgs args) { - var deletedItem = (Product)args.Item; + var deletedItem = (Product)args.Items.First(); // Delete the item in the database. await GridProductService.Delete(deletedItem); @@ -322,7 +322,7 @@ Without using the above command buttons, the application can: private async Task OnGridUpdate(GridCommandEventArgs args) { - var updatedItem = (Product)args.Item; + var updatedItem = (Product)args.Items.First(); // Update the item in the database. bool success = await GridProductService.Update(updatedItem); diff --git a/_contentTemplates/treelist/editing.md b/_contentTemplates/treelist/editing.md index 9c8e486d24..0ba410303a 100644 --- a/_contentTemplates/treelist/editing.md +++ b/_contentTemplates/treelist/editing.md @@ -54,7 +54,7 @@ Without using the above command buttons, the application can: private async Task OnTreeListCreate(TreeListCommandEventArgs args) { - var createdItem = (Employee)args.Item; + var createdItem = (Employee)args.Items.First(); var parentItem = (Employee?)args.ParentItem; await TreeListEmployeeService.Create(createdItem, parentItem); @@ -64,7 +64,7 @@ Without using the above command buttons, the application can: private async Task OnTreeListDelete(TreeListCommandEventArgs args) { - var deletedItem = (Employee)args.Item; + var deletedItem = (Employee)args.Items.First(); await TreeListEmployeeService.Delete(deletedItem); @@ -73,7 +73,7 @@ Without using the above command buttons, the application can: private async Task OnTreeListUpdate(TreeListCommandEventArgs args) { - var updatedItem = (Employee)args.Item; + var updatedItem = (Employee)args.Items.First(); await TreeListEmployeeService.Update(updatedItem); diff --git a/common-features/loading-sign.md b/common-features/loading-sign.md index 813b357413..a7bf884bb7 100644 --- a/common-features/loading-sign.md +++ b/common-features/loading-sign.md @@ -133,7 +133,7 @@ This sample shows only an indicator for the initial data load, only the DELETE o { await Task.Delay(2000); // artificial delay to showcase the concept - GridData.Remove(e.Item as SampleData); + GridData.Remove((SampleData)e.Items.First()); } public class SampleData diff --git a/components/grid/accessibility/overview.md b/components/grid/accessibility/overview.md index 8e7b6c46cd..9933cf91d0 100644 --- a/components/grid/accessibility/overview.md +++ b/components/grid/accessibility/overview.md @@ -353,7 +353,7 @@ The following example demonstrates the [accessibility compliance of the Grid com // CUD operations for the grid private void CreateItem(GridCommandEventArgs args) { - var argsItem = args.Item as SampleData; + var argsItem = args.Items.First() as SampleData; // call the actual data service here @@ -373,7 +373,7 @@ The following example demonstrates the [accessibility compliance of the Grid com private void UpdateHandler(GridCommandEventArgs args) { - var argsItem = args.Item as SampleData; + var argsItem = args.Items.First() as SampleData; // call the actual data service here diff --git a/components/grid/columns/auto-generated.md b/components/grid/columns/auto-generated.md index 15504ab130..298e8c4335 100644 --- a/components/grid/columns/auto-generated.md +++ b/components/grid/columns/auto-generated.md @@ -284,7 +284,7 @@ This example shows how to: #region CUD operations async Task UpdateItem(GridCommandEventArgs args) { - GridDataModel item = (GridDataModel)args.Item; + GridDataModel item = (GridDataModel)args.Items.First(); // perform actual data source operations here through your service await MyService.Update(item); @@ -295,7 +295,7 @@ This example shows how to: async Task DeleteItem(GridCommandEventArgs args) { - GridDataModel item = (GridDataModel)args.Item; + GridDataModel item = (GridDataModel)args.Items.First(); // perform actual data source operation here through your service await MyService.Delete(item); @@ -306,7 +306,7 @@ This example shows how to: async Task CreateItem(GridCommandEventArgs args) { - GridDataModel item = (GridDataModel)args.Item; + GridDataModel item = (GridDataModel)args.Items.First(); // perform actual data source operation here through your service await MyService.Create(item); diff --git a/components/grid/columns/command.md b/components/grid/columns/command.md index f57e3a1c00..97f43ebf19 100644 --- a/components/grid/columns/command.md +++ b/components/grid/columns/command.md @@ -143,7 +143,7 @@ The following code example demonstrates declarations and handling. private async Task CustomSaveOnClickHandler(GridCommandEventArgs args) { - SampleData theUpdatedItem = args.Item as SampleData; + SampleData theUpdatedItem = args.Items.First() as SampleData; // any custom logic if (theUpdatedItem.Name.Contains("3")) { @@ -156,7 +156,7 @@ The following code example demonstrates declarations and handling. MarkupString CustomCommandResult; private async Task MyCustomCommandOnClickHandler(GridCommandEventArgs args) { - CustomCommandResult = new MarkupString(CustomCommandResult + string.Format("
Custom command triggered for item {0}", (args.Item as SampleData).ID)); + CustomCommandResult = new MarkupString(CustomCommandResult + string.Format("
Custom command triggered for item {0}", (args.Items.First() as SampleData).ID)); Console.WriteLine("The Custom command fired. Please wait for the long operation to finish"); @@ -166,7 +166,7 @@ The following code example demonstrates declarations and handling. private async Task MyOnUpdateHandler(GridCommandEventArgs args) { - SampleData theUpdatedItem = args.Item as SampleData; + SampleData theUpdatedItem = args.Items.First() as SampleData; // perform actual data source operations here through your service await MyService.Update(theUpdatedItem); diff --git a/components/grid/columns/stacked.md b/components/grid/columns/stacked.md index 8e3a3b9c90..aa6c720706 100644 --- a/components/grid/columns/stacked.md +++ b/components/grid/columns/stacked.md @@ -165,7 +165,7 @@ The following sample shows how to: private void OnGridCreate(GridCommandEventArgs args) { - var createdItem = (Product)args.Item; + var createdItem = (Product)args.Items.First(); createdItem.Id = ++LastId; @@ -174,7 +174,7 @@ The following sample shows how to: private void OnGridUpdate(GridCommandEventArgs args) { - var updatedItem = (Product)args.Item; + var updatedItem = (Product)args.Items.First(); var originalItemIndex = GridData.FindIndex(i => i.Id == updatedItem.Id); if (originalItemIndex != -1) diff --git a/components/grid/data-binding.md b/components/grid/data-binding.md index c93abbdfca..5c0e626650 100644 --- a/components/grid/data-binding.md +++ b/components/grid/data-binding.md @@ -124,7 +124,7 @@ Note the usage of [`OnModelInit`](slug:grid-events#onmodelinit) in the example b public void UpdateHandler(GridCommandEventArgs args) { - var model = (IModel)args.Item; + var model = (IModel)args.Items.First(); var matchingItem = GridData.FirstOrDefault(c => c.Id == model.Id); @@ -136,14 +136,14 @@ Note the usage of [`OnModelInit`](slug:grid-events#onmodelinit) in the example b public void DeleteHandler(GridCommandEventArgs args) { - var model = (IModel)args.Item; + var model = (IModel)args.Items.First(); GridData.Remove(model); } public void CreateHandler(GridCommandEventArgs args) { - var model = (IModel)args.Item; + var model = (IModel)args.Items.First(); model.Id = GridData.Max(d => d.Id) + 1; diff --git a/components/grid/editing/overview.md b/components/grid/editing/overview.md index 21bc3782f0..23910f8732 100644 --- a/components/grid/editing/overview.md +++ b/components/grid/editing/overview.md @@ -153,7 +153,7 @@ All events in the [Events table](#events), except `OnModelInit`, provide a [`Gri | `Field` | `string` | The [column `Field` name](slug:components/grid/columns/bound#data-binding). Applicable only for [in-cell edit mode](slug:grid-editing-incell). | | `IsCancelled` | `bool` | Defines if the user action should be prevented. See the [Events table](#events) for details. | | `IsNew` | `bool` | Defines if `Item` is a newly added row or an existing row. | -| `Item` | `object` | The data item, which the user is adding, deleting, or editing. Cast it to the Grid model type. | +| `Items` | `IEnumerable` | The data items, which the user is adding, deleting, or editing. Cast the collection to the Grid model type. Until [batch editing](https://feedback.telerik.com/blazor/1428492-batch-editing) is implemented, only [delete operations](#delete-operations) can provide multiple items in the event argument, which can happen if users [delete multiple selected rows with the `GridToolBarDeleteTool`](slug:components/grid/features/toolbar#toolbar-tools-configuration). | | `Value` | `object` | The data item value, which the user is editing. You can cast it to the correct type, based on the `Field`. Applicable only for [in-cell edit mode](slug:grid-editing-incell). | ## Column Editors diff --git a/components/grid/editing/validation.md b/components/grid/editing/validation.md index 90cec9e882..a5c0ba83a3 100644 --- a/components/grid/editing/validation.md +++ b/components/grid/editing/validation.md @@ -115,7 +115,7 @@ Install the [`Blazilla` NuGet package](https://www.nuget.org/packages/Blazilla) private void OnGridCreate(GridCommandEventArgs args) { - var createdItem = (Product)args.Item; + var createdItem = (Product)args.Items.First(); createdItem.Id = ++LastId; @@ -124,7 +124,7 @@ Install the [`Blazilla` NuGet package](https://www.nuget.org/packages/Blazilla) private void OnGridUpdate(GridCommandEventArgs args) { - var updatedItem = (Product)args.Item; + var updatedItem = (Product)args.Items.First(); int originalItemIndex = GridData.FindIndex(i => i.Id == updatedItem.Id); if (originalItemIndex != -1) diff --git a/components/grid/events.md b/components/grid/events.md index b54dc4d571..12c479229b 100644 --- a/components/grid/events.md +++ b/components/grid/events.md @@ -112,7 +112,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri async Task UpdateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); // perform actual data source operations here through your service await MyService.Update(item); @@ -123,7 +123,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri async Task DeleteHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); await MyService.Delete(item); @@ -134,7 +134,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri async Task CreateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); // perform actual data source operation here through your service await MyService.Create(item); @@ -145,7 +145,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri void CancelHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); } protected override async Task OnInitializedAsync() @@ -243,7 +243,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri async Task UpdateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); // perform actual data source operations here through your service await MyService.Update(item); @@ -254,7 +254,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri async Task DeleteHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); await MyService.Delete(item); @@ -265,7 +265,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri async Task CreateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); // perform actual data source operation here through your service await MyService.Create(item); @@ -276,7 +276,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri void CancelHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); } protected override async Task OnInitializedAsync() @@ -380,7 +380,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri async Task UpdateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); // perform actual data source operations here through your service await MyService.Update(item); @@ -391,7 +391,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri async Task DeleteHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); await MyService.Delete(item); @@ -402,7 +402,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri async Task CreateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); // perform actual data source operation here through your service await MyService.Create(item); @@ -413,7 +413,7 @@ Read more about them and find code examples in the [Grid Export Events](slug:gri void CancelHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); } protected override async Task OnInitializedAsync() diff --git a/components/grid/state.md b/components/grid/state.md index 55eeb6fe4b..5f6706d2a0 100644 --- a/components/grid/state.md +++ b/components/grid/state.md @@ -320,7 +320,7 @@ Find out how to [get the applied filtering, sorting and grouping criteria](slug: private void OnGridUpdate(GridCommandEventArgs args) { - var updatedItem = (Product)args.Item; + var updatedItem = (Product)args.Items.First(); var originalItemIndex = GridData.FindIndex(x => x.Id == updatedItem.Id); GridData[originalItemIndex] = updatedItem; @@ -328,7 +328,7 @@ Find out how to [get the applied filtering, sorting and grouping criteria](slug: private void OnGridCreate(GridCommandEventArgs args) { - var createdItem = (Product)args.Item; + var createdItem = (Product)args.Items.First(); GridData.Insert(0, createdItem); } diff --git a/components/grid/templates/command-column-header.md b/components/grid/templates/command-column-header.md index 9d95be6860..9abe4141db 100644 --- a/components/grid/templates/command-column-header.md +++ b/components/grid/templates/command-column-header.md @@ -47,7 +47,7 @@ The `HeaderTemplate` of the Grid command column enables you to customize the hea private async Task OnUpdateHandler(GridCommandEventArgs args) { - var updatedItem = args.Item as Product; + var updatedItem = args.Items.First() as Product; var index = GridData.FindIndex(p => p.Id == updatedItem.Id); if (index != -1) { diff --git a/components/grid/templates/editor.md b/components/grid/templates/editor.md index d65e2d72e0..0efe98c8c8 100644 --- a/components/grid/templates/editor.md +++ b/components/grid/templates/editor.md @@ -129,7 +129,7 @@ The Grid will save changes and close the current edit row (or edit cell) when th private async Task OnGridUpdate(GridCommandEventArgs args) { - var item = (Product)args.Item; + var item = (Product)args.Items.First(); var index = Products.FindIndex(x => x.Id == item.Id); Products[index] = item; @@ -196,7 +196,7 @@ The Grid will save changes and close the current edit row (or edit cell) when th public async Task UpdateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); // perform actual data source operations here through your service await MyService.Update(item); @@ -322,7 +322,7 @@ Also check the [Grid Foreign Key Column](slug:grids-foreign-key) knowledge base async Task UpdateHandler(GridCommandEventArgs args) { - Employee item = (Employee)args.Item; + Employee item = (Employee)args.Items.First(); // perform actual data source operations here through your service await MyService.Update(item); diff --git a/components/grid/toolbar.md b/components/grid/toolbar.md index ef3519a48e..b65928029a 100644 --- a/components/grid/toolbar.md +++ b/components/grid/toolbar.md @@ -62,7 +62,8 @@ Add a `` tag inside `` to configure a toolbar, for exa >caption Grid Toolbar Tools ````RAZOR -` tag inside `` to configure a toolbar, for exa Pageable="true" SelectionMode="@GridSelectionMode.Multiple" @bind-SelectedItems="@SelectedPeople" - AdaptiveMode="AdaptiveMode.Auto" - OnUpdate=@UpdateItem - OnCreate=@CreateItem - OnDelete="@DeleteItem"> + AdaptiveMode="@AdaptiveMode.Auto" + OnUpdate="@UpdateItem" + OnCreate="@CreateItem" + OnDelete="@DeleteItems"> ` tag inside `` to configure a toolbar, for exa - - - - + + + + @@ -141,7 +142,7 @@ Add a `` tag inside `` to configure a toolbar, for exa private void CreateItem(GridCommandEventArgs args) { - var createdItem = (Person)args.Item; + var createdItem = (Person)args.Items.First(); createdItem.EmployeeId = GridData.Count + 1; @@ -150,7 +151,7 @@ Add a `` tag inside `` to configure a toolbar, for exa private void UpdateItem(GridCommandEventArgs args) { - var updatedItem = (Person)args.Item; + var updatedItem = (Person)args.Items.First(); var itemForEdit = GridData.FirstOrDefault(i => i.EmployeeId == updatedItem.EmployeeId); if (itemForEdit != null) @@ -161,13 +162,16 @@ Add a `` tag inside `` to configure a toolbar, for exa } } - private void DeleteItem(GridCommandEventArgs args) + private void DeleteItems(GridCommandEventArgs args) { - var deletedItem = (Person)args.Item; + var deletedItems = args.Items.Cast(); - if (GridData.Contains(deletedItem)) + foreach (Person personToDelete in deletedItems) { - GridData.Remove(deletedItem); + if (GridData.Contains(personToDelete)) + { + GridData.Remove(personToDelete); + } } } diff --git a/components/treelist/accessibility/overview.md b/components/treelist/accessibility/overview.md index 72e25c7409..d04424c96c 100644 --- a/components/treelist/accessibility/overview.md +++ b/components/treelist/accessibility/overview.md @@ -524,7 +524,7 @@ The following example demonstrates the [accessibility compliance of the TreeList #region TreeList CUD private async Task UpdateItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; await MyService.Update(item); @@ -533,7 +533,7 @@ The following example demonstrates the [accessibility compliance of the TreeList private async Task CreateItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; var parentItem = args.ParentItem as Employee; await MyService.Create(item, parentItem); @@ -543,7 +543,7 @@ The following example demonstrates the [accessibility compliance of the TreeList private async Task DeleteItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; await MyService.Delete(item); @@ -552,12 +552,12 @@ The following example demonstrates the [accessibility compliance of the TreeList private async Task OnEditHandler(TreeListCommandEventArgs args) { - Employee empl = args.Item as Employee; + Employee empl = args.Items.First() as Employee; } private async Task OnCancelHandler(TreeListCommandEventArgs args) { - Employee empl = args.Item as Employee; + Employee empl = args.Items.First() as Employee; } #endregion diff --git a/components/treelist/columns/auto-generated.md b/components/treelist/columns/auto-generated.md index 2b1cd379ce..5e343045cf 100644 --- a/components/treelist/columns/auto-generated.md +++ b/components/treelist/columns/auto-generated.md @@ -374,7 +374,7 @@ This example shows how to: async Task UpdateHandler(TreeListCommandEventArgs e) { - var item = e.Item as Employee; + var item = e.Items.First() as Employee; // perform actual data source operations here through your service await MyService.Update(item); diff --git a/components/treelist/data-binding/interface.md b/components/treelist/data-binding/interface.md index 3de3aa526f..cd4c805c27 100644 --- a/components/treelist/data-binding/interface.md +++ b/components/treelist/data-binding/interface.md @@ -89,7 +89,7 @@ Note the usage of [`OnModelInit`](slug:treelist-events#onmodelinit) in the examp public void UpdateHandler(TreeListCommandEventArgs args) { - var model = (IModel)args.Item; + var model = (IModel)args.Items.First(); var matchingItem = TreeListData.FirstOrDefault(c => c.Id == model.Id); @@ -101,14 +101,14 @@ Note the usage of [`OnModelInit`](slug:treelist-events#onmodelinit) in the examp public void DeleteHandler(TreeListCommandEventArgs args) { - var model = (IModel)args.Item; + var model = (IModel)args.Items.First(); TreeListData.Remove(model); } public void CreateHandler(TreeListCommandEventArgs args) { - var model = (IModel)args.Item; + var model = (IModel)args.Items.First(); model.Id = TreeListData.Max(d => d.Id) + 1; diff --git a/components/treelist/editing/overview.md b/components/treelist/editing/overview.md index 640fa4d7f7..3af04c0b59 100644 --- a/components/treelist/editing/overview.md +++ b/components/treelist/editing/overview.md @@ -152,7 +152,7 @@ All events in the [Events table](#events), except `OnModelInit`, provide a [`Tre | `Field` | `string` | The [column `Field` name](slug:treelist-columns-bound#data-binding). Applicable only for [in-cell edit mode](slug:treelist-editing-incell). | | `IsCancelled` | `bool` | Defines if the user action should be prevented. See the [Events table](#events) for details. | | `IsNew` | `bool` | Defines if `Item` is a newly added row or an existing row. | -| `Item` | `object` | The data item, which the user is adding, deleting, or editing. Cast it to the TreeList model type. | +| `Items` | `IEnumerable` | The data item, which the user is adding, deleting, or editing. Cast the collection to the TreeList model type. Until [batch editing](https://feedback.telerik.com/blazor/1428492-batch-editing) is implemented, the collection can contain only one member. | | `ParentItem` | `object?` | The parent of the data item, which the user is adding. Available only in the `OnCreate` event. Cast the object to the TreeList model type. | | `Value` | `object` | The data item value, which the user is editing. You can cast it to the correct type, based on the `Field`. Applicable only for [in-cell edit mode](slug:treelist-editing-incell). | diff --git a/components/treelist/editing/validation.md b/components/treelist/editing/validation.md index 561500c6ca..0d837334cd 100644 --- a/components/treelist/editing/validation.md +++ b/components/treelist/editing/validation.md @@ -122,7 +122,7 @@ Install the [`Blazilla` NuGet package](https://www.nuget.org/packages/Blazilla) private async Task OnTreeListCreate(TreeListCommandEventArgs args) { - var createdItem = (Employee)args.Item; + var createdItem = (Employee)args.Items.First(); var parentItem = (Employee?)args.ParentItem; await TreeListEmployeeService.Create(createdItem, parentItem); @@ -132,7 +132,7 @@ Install the [`Blazilla` NuGet package](https://www.nuget.org/packages/Blazilla) private async Task OnTreeListUpdate(TreeListCommandEventArgs args) { - var updatedItem = (Employee)args.Item; + var updatedItem = (Employee)args.Items.First(); await TreeListEmployeeService.Update(updatedItem); diff --git a/components/treelist/events.md b/components/treelist/events.md index b34df81bad..4c5e64aafb 100644 --- a/components/treelist/events.md +++ b/components/treelist/events.md @@ -232,7 +232,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele // Sample CUD operations for the local data async Task UpdateItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; // perform actual data source operations here through your service await MyService.Update(item); @@ -243,7 +243,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele async Task CreateItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; var parentItem = args.ParentItem as Employee; // perform actual data source operations here through your service @@ -255,7 +255,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele async Task DeleteItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; // perform actual data source operations here through your service await MyService.Delete(item); @@ -268,7 +268,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele async Task OnCancelHandler(TreeListCommandEventArgs args) { - Employee empl = args.Item as Employee; + Employee empl = args.Items.First() as Employee; // if necessary, perform actual data source operation here through your service } @@ -486,7 +486,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele // Sample CUD operations for the local data async Task UpdateItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; // perform actual data source operations here through your service await MyService.Update(item); @@ -497,7 +497,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele async Task CreateItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; var parentItem = args.ParentItem as Employee; // perform actual data source operations here through your service @@ -509,7 +509,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele async Task DeleteItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; // perform actual data source operations here through your service await MyService.Delete(item); @@ -522,7 +522,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele async Task OnCancelHandler(TreeListCommandEventArgs args) { - Employee empl = args.Item as Employee; + Employee empl = args.Items.First() as Employee; // if necessary, perform actual data source operation here through your service } @@ -750,7 +750,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele // Sample CUD operations for the local data async Task UpdateItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; // perform actual data source operations here through your service await MyService.Update(item); @@ -761,7 +761,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele async Task CreateItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; var parentItem = args.ParentItem as Employee; // perform actual data source operations here through your service @@ -773,7 +773,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele async Task DeleteItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; // perform actual data source operations here through your service await MyService.Delete(item); @@ -786,7 +786,7 @@ Visit the [TreeList Cell Selection article to see an example](slug:treelist-sele async Task OnCancelHandler(TreeListCommandEventArgs args) { - Employee empl = args.Item as Employee; + Employee empl = args.Items.First() as Employee; // if necessary, perform actual data source operation here through your service } diff --git a/components/treelist/state.md b/components/treelist/state.md index d9029e25a4..5b5163f6fa 100644 --- a/components/treelist/state.md +++ b/components/treelist/state.md @@ -303,7 +303,7 @@ Find out how to [get the applied filtering and sorting criteria](slug:common-fea private async Task OnTreeListCreate(TreeListCommandEventArgs args) { - var createdItem = (Employee)args.Item; + var createdItem = (Employee)args.Items.First(); var parentItem = (Employee?)args.ParentItem; await TreeListEmployeeService.Create(createdItem, parentItem); @@ -313,7 +313,7 @@ Find out how to [get the applied filtering and sorting criteria](slug:common-fea private async Task OnTreeListUpdate(TreeListCommandEventArgs args) { - var updatedItem = (Employee)args.Item; + var updatedItem = (Employee)args.Items.First(); await TreeListEmployeeService.Update(updatedItem); diff --git a/components/treelist/templates/editor.md b/components/treelist/templates/editor.md index 718f9d59e1..03862a8f69 100644 --- a/components/treelist/templates/editor.md +++ b/components/treelist/templates/editor.md @@ -69,7 +69,7 @@ The TreeList row creates an `EditContext` and passes it to the `EditorTemplate`. // Sample CUD operations for the local data async Task UpdateItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; // perform actual data source operations here through your service await MyService.Update(item); diff --git a/components/treelist/templates/popup-buttons-template.md b/components/treelist/templates/popup-buttons-template.md index a6a7fd50e9..faa4b725e3 100644 --- a/components/treelist/templates/popup-buttons-template.md +++ b/components/treelist/templates/popup-buttons-template.md @@ -129,7 +129,7 @@ With the `ButtonsTemplate`, you can personalize the appearance and behavior of t private void UpdateItem(TreeListCommandEventArgs args) { - var item = args.Item as HierarchicalModel; + var item = args.Items.First() as HierarchicalModel; var foundItem = FindItemRecursive(Data, item.Id); if (foundItem != null) @@ -165,7 +165,7 @@ With the `ButtonsTemplate`, you can personalize the appearance and behavior of t private void DeleteItem(TreeListCommandEventArgs args) { - var item = args.Item as HierarchicalModel; + var item = args.Items.First() as HierarchicalModel; RemoveChildRecursive(Data, item); } @@ -194,7 +194,7 @@ With the `ButtonsTemplate`, you can personalize the appearance and behavior of t private void CreateItem(TreeListCommandEventArgs args) { - var argsItem = args.Item as HierarchicalModel; + var argsItem = args.Items.First() as HierarchicalModel; argsItem.Id = LastId++; diff --git a/components/treelist/templates/popup-form-template.md b/components/treelist/templates/popup-form-template.md index 7cee1c29e9..84f6749462 100644 --- a/components/treelist/templates/popup-form-template.md +++ b/components/treelist/templates/popup-form-template.md @@ -160,7 +160,7 @@ You can use the `Context` attribute of the `` tag to set the name private void DeleteItem(TreeListCommandEventArgs args) { - var item = args.Item as HierarchicalModel; + var item = args.Items.First() as HierarchicalModel; RemoveChildRecursive(Data, item); } diff --git a/components/treelist/toolbar.md b/components/treelist/toolbar.md index 22a05e15b0..5a78060f7d 100644 --- a/components/treelist/toolbar.md +++ b/components/treelist/toolbar.md @@ -126,7 +126,7 @@ Add a `` tag inside `` to configure a toolbar, private void UpdateItem(TreeListCommandEventArgs args) { - var item = args.Item as HierarchicalModel; + var item = args.Items.First() as HierarchicalModel; var foundItem = FindItemRecursive(Data, item.Id); if (foundItem != null) @@ -162,7 +162,7 @@ Add a `` tag inside `` to configure a toolbar, private void DeleteItem(TreeListCommandEventArgs args) { - var item = args.Item as HierarchicalModel; + var item = args.Items.First() as HierarchicalModel; RemoveChildRecursive(Data, item); } @@ -191,7 +191,7 @@ Add a `` tag inside `` to configure a toolbar, private void CreateItem(TreeListCommandEventArgs args) { - var argsItem = args.Item as HierarchicalModel; + var argsItem = args.Items.First() as HierarchicalModel; argsItem.Id = LastId++; @@ -267,7 +267,7 @@ When using a ``, you need to use the `Tab` key to navig private string result; private async Task MyCommandFromToolbar(TreeListCommandEventArgs args) { - //note - the args.Item object is null because the command item is not associated with an item + //note - args.Items is null because the command item is not associated with an item result = "my custom toolbar command fired at " + DateTime.Now.ToString(); } diff --git a/knowledge-base/grid-add-edit-state.md b/knowledge-base/grid-add-edit-state.md index 93a24e7202..fd68c3549d 100644 --- a/knowledge-base/grid-add-edit-state.md +++ b/knowledge-base/grid-add-edit-state.md @@ -224,7 +224,7 @@ All these operations can also be used for [`Incell`](slug:grid-editing-incell). private void OnGridInlineUpdate(GridCommandEventArgs args) { - var updatedItem = (Product)args.Item; + var updatedItem = (Product)args.Items.First(); var index = GridInlineData.FindIndex(i => i.Id == updatedItem.Id); if (index != -1) { @@ -234,7 +234,7 @@ All these operations can also be used for [`Incell`](slug:grid-editing-incell). private void OnGridInlineCreate(GridCommandEventArgs args) { - var createdItem = (Product)args.Item; + var createdItem = (Product)args.Items.First(); createdItem.Id = Guid.NewGuid(); GridInlineData.Insert(0, createdItem); } @@ -245,7 +245,7 @@ All these operations can also be used for [`Incell`](slug:grid-editing-incell). private void OnGridIncellUpdate(GridCommandEventArgs args) { - var updatedItem = (Product)args.Item; + var updatedItem = (Product)args.Items.First(); var index = GridIncellData.FindIndex(i => i.Id == updatedItem.Id); if (index != -1) { @@ -255,7 +255,7 @@ All these operations can also be used for [`Incell`](slug:grid-editing-incell). private void OnGridIncellCreate(GridCommandEventArgs args) { - var createdItem = (Product)args.Item; + var createdItem = (Product)args.Items.First(); createdItem.Id = Guid.NewGuid(); GridIncellData.Insert(0, createdItem); } diff --git a/knowledge-base/grid-autofill-default-value-double-click.md b/knowledge-base/grid-autofill-default-value-double-click.md index da43e0ad2d..8145180b88 100644 --- a/knowledge-base/grid-autofill-default-value-double-click.md +++ b/knowledge-base/grid-autofill-default-value-double-click.md @@ -60,7 +60,7 @@ To autofill a default value in the cell on double-click during inline editing, u private async Task OnGridUpdate(GridCommandEventArgs args) { - var item = (Product)args.Item; + var item = (Product)args.Items.First(); var index = Products.FindIndex(x => x.Id == item.Id); Products[index] = item; diff --git a/knowledge-base/grid-bind-navigation-property-complex-object.md b/knowledge-base/grid-bind-navigation-property-complex-object.md index 33476a8bbf..e1de5981dc 100644 --- a/knowledge-base/grid-bind-navigation-property-complex-object.md +++ b/knowledge-base/grid-bind-navigation-property-complex-object.md @@ -194,7 +194,7 @@ The example below demonstrates all three options. Pick one, according to your pr private void OnGridUpdate(GridCommandEventArgs args) { - var updatedItem = (SampleComplexObject)args.Item; + var updatedItem = (SampleComplexObject)args.Items.First(); var originalItemIndex = GridData.FindIndex(i => i.Id == updatedItem.Id); if (originalItemIndex != -1) @@ -205,7 +205,7 @@ The example below demonstrates all three options. Pick one, according to your pr private void OnGridCreate(GridCommandEventArgs args) { - var createdItem = (SampleComplexObject)args.Item; + var createdItem = (SampleComplexObject)args.Items.First(); createdItem.Id = ++LastId; GridData.Insert(0, createdItem); diff --git a/knowledge-base/grid-binding-to-expando-object.md b/knowledge-base/grid-binding-to-expando-object.md index db7fc36ac5..21fe22f7b8 100644 --- a/knowledge-base/grid-binding-to-expando-object.md +++ b/knowledge-base/grid-binding-to-expando-object.md @@ -103,12 +103,12 @@ The key points in the required implementation are: private async Task OnGridEdit(GridCommandEventArgs args) { - GridEditItem = (IDictionary)args.Item; + GridEditItem = (IDictionary)args.Items.First(); } private async Task OnGridUpdate(GridCommandEventArgs args) { - var item = (IDictionary)args.Item; + var item = (IDictionary)args.Items.First(); // There are two ways to update the data item: // Store its instance in OnEdit, or find it in the Grid Data via search by Id. @@ -148,7 +148,7 @@ The key points in the required implementation are: private async Task OnGridCreate(GridCommandEventArgs args) { - var item = args.Item as ExpandoObject; + var item = args.Items.First() as ExpandoObject; ((IDictionary)item)["Id"] = ++LastId; @@ -157,7 +157,7 @@ The key points in the required implementation are: private async Task OnGridDelete(GridCommandEventArgs args) { - var item = args.Item as ExpandoObject; + var item = args.Items.First() as ExpandoObject; GridData.Remove(item); } @@ -548,7 +548,7 @@ The following example demonstrates how the Grid can edit, filter, and group null private async Task OnGridUpdate(GridCommandEventArgs args) { - var item = (IDictionary)args.Item; + var item = (IDictionary)args.Items.First(); var originalItem = GridData.First(x => { diff --git a/knowledge-base/grid-cascade-dropdowns-for-fields.md b/knowledge-base/grid-cascade-dropdowns-for-fields.md index 58d7fedbb1..6ecfecc8fa 100644 --- a/knowledge-base/grid-cascade-dropdowns-for-fields.md +++ b/knowledge-base/grid-cascade-dropdowns-for-fields.md @@ -109,7 +109,7 @@ There are three approaches you can take: { if(CurrentlyEditedEmployee is null) { - CurrentlyEditedEmployee = args.Item as SampleData; + CurrentlyEditedEmployee = args.Items.First() as SampleData; } await CascadeSecondList(null); } @@ -119,7 +119,7 @@ There are three approaches you can take: public void UpdateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); //perform actual data source operations here diff --git a/knowledge-base/grid-change-editable-attribute-update-create.md b/knowledge-base/grid-change-editable-attribute-update-create.md index 1ab0ed9f7b..cb84f38b3c 100644 --- a/knowledge-base/grid-change-editable-attribute-update-create.md +++ b/knowledge-base/grid-change-editable-attribute-update-create.md @@ -81,7 +81,7 @@ In the two examples below, the `Name` column uses the `Editable` property, and t public void UpdateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); //perform actual data source operations here //if you have a context added through an @inject statement, you could call its SaveChanges() method @@ -192,7 +192,7 @@ In the two examples below, the `Name` column uses the `Editable` property, and t { isEditable = true; // this is the flag that we use for the Editable property - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); //perform actual data source operations here //if you have a context added through an @inject statement, you could call its SaveChanges() method diff --git a/knowledge-base/grid-conditionally-hide-command-buttons.md b/knowledge-base/grid-conditionally-hide-command-buttons.md index b7361d8cc5..2c194d9b1b 100644 --- a/knowledge-base/grid-conditionally-hide-command-buttons.md +++ b/knowledge-base/grid-conditionally-hide-command-buttons.md @@ -72,17 +72,17 @@ To conditionally show or hide command buttons in a Grid, use the context paramet private async Task HandleCustomSave(GridCommandEventArgs args) { - SampleData theUpdatedItem = args.Item as SampleData; + SampleData theUpdatedItem = args.Items.First() as SampleData; } private async Task HandleCustomButtonClick(GridCommandEventArgs args) { - CustomCommandResult = new MarkupString(CustomCommandResult + string.Format("
Custom command triggered for item {0}", (args.Item as SampleData).ID)); + CustomCommandResult = new MarkupString(CustomCommandResult + string.Format("
Custom command triggered for item {0}", (args.Items.First() as SampleData).ID)); } private async Task HandleUpdate(GridCommandEventArgs args) { - SampleData theUpdatedItem = args.Item as SampleData; + SampleData theUpdatedItem = args.Items.First() as SampleData; await MyService.Update(theUpdatedItem); @@ -178,17 +178,17 @@ If you prefer not to remove the button from the DOM but simply hide it, you can private async Task HandleCustomSave(GridCommandEventArgs args) { - SampleData theUpdatedItem = args.Item as SampleData; + SampleData theUpdatedItem = args.Items.First() as SampleData; } private async Task HandleCustomButtonClick(GridCommandEventArgs args) { - CustomCommandResult = new MarkupString(CustomCommandResult + string.Format("
Custom command triggered for item {0}", (args.Item as SampleData).ID)); + CustomCommandResult = new MarkupString(CustomCommandResult + string.Format("
Custom command triggered for item {0}", (args.Items.First() as SampleData).ID)); } private async Task HandleUpdate(GridCommandEventArgs args) { - SampleData theUpdatedItem = args.Item as SampleData; + SampleData theUpdatedItem = args.Items.First() as SampleData; await MyService.Update(theUpdatedItem); diff --git a/knowledge-base/grid-create-reusable-columns.md b/knowledge-base/grid-create-reusable-columns.md index 112e02c31f..691e4997b3 100644 --- a/knowledge-base/grid-create-reusable-columns.md +++ b/knowledge-base/grid-create-reusable-columns.md @@ -51,7 +51,7 @@ To create a reusable `GridColumn` component with templates, follow these steps: private async Task UpdateHandler(GridCommandEventArgs args) { - Employee item = (Employee)args.Item; + Employee item = (Employee)args.Items.First(); await MyService.Update(item); diff --git a/knowledge-base/grid-customize-delete-confirmation-dialog.md b/knowledge-base/grid-customize-delete-confirmation-dialog.md index 59f9c851ff..e0f0a3d3f1 100644 --- a/knowledge-base/grid-customize-delete-confirmation-dialog.md +++ b/knowledge-base/grid-customize-delete-confirmation-dialog.md @@ -110,7 +110,7 @@ Use a [Predefined Confirm Dialog](slug:dialog-predefined#confirm) with the desir private async Task OnGridUpdate(GridCommandEventArgs args) { - var updatedItem = (Product)args.Item; + var updatedItem = (Product)args.Items.First(); bool cancelled = await ShouldCancel("Updating", updatedItem.Name); if (cancelled) @@ -129,7 +129,7 @@ Use a [Predefined Confirm Dialog](slug:dialog-predefined#confirm) with the desir private async Task OnGridDelete(GridCommandEventArgs args) { - var deletedItem = (Product)args.Item; + var deletedItem = (Product)args.Items.First(); bool cancelled = await ShouldCancel("Deleting", deletedItem.Name); if (cancelled) @@ -249,7 +249,7 @@ Using the [Dialog component](slug:dialog-overview) will let you have fully custo private void OnGridSave(GridCommandEventArgs args) { - var itemToUpdate = (Product)args.Item; + var itemToUpdate = (Product)args.Items.First(); ItemToUpdate = itemToUpdate; DialogContent = new MarkupString($"

Saving product {ItemToUpdate.Name}.
Do you want to continue?

"); @@ -258,7 +258,7 @@ Using the [Dialog component](slug:dialog-overview) will let you have fully custo private void OnGridDelete(GridCommandEventArgs args) { - var deletedItem = (Product)args.Item; + var deletedItem = (Product)args.Items.First(); ItemToDelete = deletedItem; DialogContent = new MarkupString($"

Deleting product {ItemToDelete.Name}.
Do you want to continue?

"); diff --git a/knowledge-base/grid-doubleclick-starts-editing.md b/knowledge-base/grid-doubleclick-starts-editing.md index 9e9e3da545..2cd8d368c0 100644 --- a/knowledge-base/grid-doubleclick-starts-editing.md +++ b/knowledge-base/grid-doubleclick-starts-editing.md @@ -81,7 +81,7 @@ See the following example for reference: async Task UpdateHandler(GridCommandEventArgs args) { - SampleData itemToUpdate = args.Item as SampleData; + SampleData itemToUpdate = args.Items.First() as SampleData; int itemIndex = MyData.IndexOf(itemToUpdate); if (itemIndex > -1) { diff --git a/knowledge-base/grid-edit-in-hierarchy.md b/knowledge-base/grid-edit-in-hierarchy.md index 1b32442d89..08aaf553ba 100644 --- a/knowledge-base/grid-edit-in-hierarchy.md +++ b/knowledge-base/grid-edit-in-hierarchy.md @@ -125,7 +125,7 @@ Grid EditMode: { // perform actual data source operations here through your service - var item = (Product)args.Item; + var item = (Product)args.Items.First(); var index = GridData.FindIndex(x => x.ProductId == item.ProductId); if (index != -1) { @@ -136,7 +136,7 @@ Grid EditMode: { // perform actual data source operations here through your service - var item = (Product)args.Item; + var item = (Product)args.Items.First(); item.ProductId = ++LastId; @@ -148,7 +148,7 @@ Grid EditMode: { // perform actual data source operations here through your service - var item = (Product)args.Item; + var item = (Product)args.Items.First(); GridData.Remove(item); } @@ -161,7 +161,7 @@ Grid EditMode: { // perform actual data source operations here through your service - var item = (OrderDetails)args.Item; + var item = (OrderDetails)args.Items.First(); var data = product.OrderDetails; int index = data.FindIndex(x => x.OrderId == item.OrderId); if (index != -1) @@ -174,7 +174,7 @@ Grid EditMode: { // perform actual data source operations here through your service - var item = (OrderDetails)args.Item; + var item = (OrderDetails)args.Items.First(); var data = product.OrderDetails; item.OrderId = data.Count + 1; @@ -186,7 +186,7 @@ Grid EditMode: { // perform actual data source operations here through your service - var item = (OrderDetails)args.Item; + var item = (OrderDetails)args.Items.First(); var data = product.OrderDetails; data.Remove(item); diff --git a/knowledge-base/grid-edit-on-row-double-click.md b/knowledge-base/grid-edit-on-row-double-click.md index 46636ffd12..8d5c5d9da2 100644 --- a/knowledge-base/grid-edit-on-row-double-click.md +++ b/knowledge-base/grid-edit-on-row-double-click.md @@ -72,7 +72,7 @@ The Grid exposes two events that allows you to respond to the user clicking on i async Task UpdateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); // perform actual data source operations here through your service await MyService.Update(item); @@ -83,7 +83,7 @@ The Grid exposes two events that allows you to respond to the user clicking on i async Task DeleteHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); // perform actual data source operation here through your service await MyService.Delete(item); @@ -94,7 +94,7 @@ The Grid exposes two events that allows you to respond to the user clicking on i async Task CreateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); // perform actual data source operation here through your service await MyService.Create(item); diff --git a/knowledge-base/grid-expand-edited-row.md b/knowledge-base/grid-expand-edited-row.md index 723bc5ab32..5bf413395b 100644 --- a/knowledge-base/grid-expand-edited-row.md +++ b/knowledge-base/grid-expand-edited-row.md @@ -117,7 +117,7 @@ To achieve automatic expansion of a detail template for the edited or newly inse // When a row enters edit mode, expand it private async Task OnEdit(GridCommandEventArgs args) { - var editedItem = (Product)args.Item; + var editedItem = (Product)args.Items.First(); var state = GridRef.GetState(); state.ExpandedItems = new List { editedItem }; // collapse all others @@ -127,7 +127,7 @@ To achieve automatic expansion of a detail template for the edited or newly inse #region CRUD Operations for Main Grid private void UpdateProduct(GridCommandEventArgs args) { - var item = (Product)args.Item; + var item = (Product)args.Items.First(); var index = GridData.FindIndex(x => x.ProductId == item.ProductId); if (index != -1) { @@ -137,7 +137,7 @@ To achieve automatic expansion of a detail template for the edited or newly inse private void CreateProduct(GridCommandEventArgs args) { - var item = (Product)args.Item; + var item = (Product)args.Items.First(); item.ProductId = ++LastId; GridData.Insert(0, item); item.OrderDetails = GenerateOrderDetails(item); @@ -156,7 +156,7 @@ To achieve automatic expansion of a detail template for the edited or newly inse private void DeleteProduct(GridCommandEventArgs args) { - var item = (Product)args.Item; + var item = (Product)args.Items.First(); GridData.Remove(item); } #endregion @@ -164,7 +164,7 @@ To achieve automatic expansion of a detail template for the edited or newly inse #region CRUD for Details Grid private void UpdateOrder(Product product, GridCommandEventArgs args) { - var item = (OrderDetails)args.Item; + var item = (OrderDetails)args.Items.First(); var data = product.OrderDetails; int index = data.FindIndex(x => x.OrderId == item.OrderId); if (index != -1) @@ -175,7 +175,7 @@ To achieve automatic expansion of a detail template for the edited or newly inse private void CreateOrder(GridCommandEventArgs args, Product product) { - var item = (OrderDetails)args.Item; + var item = (OrderDetails)args.Items.First(); var data = product.OrderDetails; item.OrderId = data.Count + 1; data.Insert(0, item); @@ -183,7 +183,7 @@ To achieve automatic expansion of a detail template for the edited or newly inse private void DeleteOrder(GridCommandEventArgs args, Product product) { - var item = (OrderDetails)args.Item; + var item = (OrderDetails)args.Items.First(); var data = product.OrderDetails; data.Remove(item); } diff --git a/knowledge-base/grid-filter-date-only.md b/knowledge-base/grid-filter-date-only.md index 47aa1f4c35..ebd2109d5f 100644 --- a/knowledge-base/grid-filter-date-only.md +++ b/knowledge-base/grid-filter-date-only.md @@ -254,7 +254,7 @@ This approach is suitable for both filter menu and filter row modes. It has the void OnGridUpdate(GridCommandEventArgs args) { - var item = args.Item as GridItem; + var item = args.Items.First() as GridItem; var index = GridData.FindIndex(x => x.Id == item.Id); GridData[index] = item; } diff --git a/knowledge-base/grid-filter-edit-enum.md b/knowledge-base/grid-filter-edit-enum.md index ab087e9316..d67aed8cba 100644 --- a/knowledge-base/grid-filter-edit-enum.md +++ b/knowledge-base/grid-filter-edit-enum.md @@ -75,7 +75,7 @@ To control how each enum value will show in the filtering DropDownList, decorate private void UpdateHandler(GridCommandEventArgs args) { - SampleData item = (SampleData)args.Item; + SampleData item = (SampleData)args.Items.First(); //update the view-model var index = MyData.FindIndex(i => i.ID == item.ID); diff --git a/knowledge-base/grid-handle-empty-popup-footer.md b/knowledge-base/grid-handle-empty-popup-footer.md index 7fa3abe41a..4942c86c70 100644 --- a/knowledge-base/grid-handle-empty-popup-footer.md +++ b/knowledge-base/grid-handle-empty-popup-footer.md @@ -156,7 +156,7 @@ To display custom buttons in the footer and handle form submission, follow these private void DeleteItem(GridCommandEventArgs args) { - DeletePerson(args.Item as Person); + DeletePerson(args.Items.First() as Person); LoadData(); } @@ -364,7 +364,7 @@ This approach relies on using CSS to hide the empty footer. Add your custom clas private void DeleteItem(GridCommandEventArgs args) { - DeletePerson(args.Item as Person); + DeletePerson(args.Items.First() as Person); LoadData(); } diff --git a/knowledge-base/grid-incell-add-new-row-enter.md b/knowledge-base/grid-incell-add-new-row-enter.md index a62fd6b8cf..14a1b9abdb 100644 --- a/knowledge-base/grid-incell-add-new-row-enter.md +++ b/knowledge-base/grid-incell-add-new-row-enter.md @@ -171,7 +171,7 @@ function getLastKey() { private async Task OnGridUpdate(GridCommandEventArgs args) { - var item = args.Item as Product; + var item = args.Items.First() as Product; var index = GridData.FindIndex(i => i.Id == item.Id); if (index != -1) @@ -187,7 +187,7 @@ function getLastKey() { private void OnGridCreate(GridCommandEventArgs args) { - var item = args.Item as Product; + var item = args.Items.First() as Product; item.Id = ++LastId; GridData.Insert(0, item); @@ -195,7 +195,7 @@ function getLastKey() { private void OnGridDelete(GridCommandEventArgs args) { - var item = args.Item as Product; + var item = args.Items.First() as Product; GridData.Remove(item); } diff --git a/knowledge-base/grid-incell-dropdown-opening-behavior.md b/knowledge-base/grid-incell-dropdown-opening-behavior.md index 129d77b3cf..e9213ce6c6 100644 --- a/knowledge-base/grid-incell-dropdown-opening-behavior.md +++ b/knowledge-base/grid-incell-dropdown-opening-behavior.md @@ -68,7 +68,7 @@ To reproduce, double click quickly a row in the `Role` column. public void UpdateHandler(GridCommandEventArgs args) { - var argsItem = args.Item as Employee; + var argsItem = args.Items.First() as Employee; var index = GridData.FindIndex(i => i.EmployeeId == argsItem.EmployeeId); if (index != -1) { @@ -165,7 +165,7 @@ The sample below demonstrates how to achieve the desired behavior by using the ` public void UpdateHandler(GridCommandEventArgs args) { - var argsItem = args.Item as Employee; + var argsItem = args.Items.First() as Employee; var index = GridData.FindIndex(i => i.EmployeeId == argsItem.EmployeeId); if (index != -1) { diff --git a/knowledge-base/grid-load-cached-data-after-crud-operations.md b/knowledge-base/grid-load-cached-data-after-crud-operations.md index 1da9b1045a..fc32576768 100644 --- a/knowledge-base/grid-load-cached-data-after-crud-operations.md +++ b/knowledge-base/grid-load-cached-data-after-crud-operations.md @@ -69,7 +69,7 @@ Use the [Grid CUD event arguments](slug:grid-editing-overview#events) to update private async Task OnGridCreate(GridCommandEventArgs args) { - var createdItem = (Product)args.Item; + var createdItem = (Product)args.Items.First(); int createdItemId = await GridProductService.Create(createdItem); createdItem.Id = createdItemId; @@ -78,7 +78,7 @@ Use the [Grid CUD event arguments](slug:grid-editing-overview#events) to update private async Task OnGridDelete(GridCommandEventArgs args) { - var deletedItem = (Product)args.Item; + var deletedItem = (Product)args.Items.First(); await GridProductService.Delete(deletedItem); @@ -87,7 +87,7 @@ Use the [Grid CUD event arguments](slug:grid-editing-overview#events) to update private async Task OnGridUpdate(GridCommandEventArgs args) { - var updatedItem = (Product)args.Item; + var updatedItem = (Product)args.Items.First(); await GridProductService.Update(updatedItem); @@ -256,7 +256,7 @@ Use the [Grid CUD event arguments](slug:grid-editing-overview#events) to update private async Task OnGridCreate(GridCommandEventArgs args) { - var createdItem = (Product)args.Item; + var createdItem = (Product)args.Items.First(); int createdItemId = await GridProductService.Create(createdItem); @@ -268,7 +268,7 @@ Use the [Grid CUD event arguments](slug:grid-editing-overview#events) to update private async Task OnGridDelete(GridCommandEventArgs args) { - var deletedItem = (Product)args.Item; + var deletedItem = (Product)args.Items.First(); await GridProductService.Delete(deletedItem); @@ -304,7 +304,7 @@ Use the [Grid CUD event arguments](slug:grid-editing-overview#events) to update private async Task OnGridUpdate(GridCommandEventArgs args) { - var updatedItem = (Product)args.Item; + var updatedItem = (Product)args.Items.First(); await GridProductService.Update(updatedItem); diff --git a/knowledge-base/grid-loader-during-contextmenu-actions.md b/knowledge-base/grid-loader-during-contextmenu-actions.md index d199a1a7a0..1304a2fb53 100644 --- a/knowledge-base/grid-loader-during-contextmenu-actions.md +++ b/knowledge-base/grid-loader-during-contextmenu-actions.md @@ -173,7 +173,7 @@ To display a spinner during delayed operations initiated from a ContextMenu in a private async Task CreateItem(GridCommandEventArgs args) { - var argsItem = args.Item as SampleData; + var argsItem = args.Items.First() as SampleData; argsItem.ID = GridData.Count + 1; @@ -182,7 +182,7 @@ To display a spinner during delayed operations initiated from a ContextMenu in a private async Task UpdateHandler(GridCommandEventArgs args) { - var argsItem = args.Item as SampleData; + var argsItem = args.Items.First() as SampleData; var index = GridData.ToList().FindIndex(i => i.ID == argsItem.ID); if (index != -1) diff --git a/knowledge-base/grid-multiselect-editor.md b/knowledge-base/grid-multiselect-editor.md index 2436590739..aca3f40a92 100644 --- a/knowledge-base/grid-multiselect-editor.md +++ b/knowledge-base/grid-multiselect-editor.md @@ -88,7 +88,7 @@ Add the [Multi Select component](slug:multiselect-overview) to the [EditorTempla async Task UpdateHandler(GridCommandEventArgs args) { - Team item = (Team)args.Item; + Team item = (Team)args.Items.First(); // perform actual data source operations here through your service await MyService.Update(item); diff --git a/knowledge-base/grid-popup-edit-title.md b/knowledge-base/grid-popup-edit-title.md index ade890274c..558cb87d63 100644 --- a/knowledge-base/grid-popup-edit-title.md +++ b/knowledge-base/grid-popup-edit-title.md @@ -70,14 +70,14 @@ How to dynamically set the Grid popup edit Window title? private void OnGridEdit(GridCommandEventArgs args) { - var item = args.Item as Product; + var item = args.Items.First() as Product; PopupTitle = "Editing " + item.Name; } private void OnGridUpdate(GridCommandEventArgs args) { - var item = args.Item as Product; + var item = args.Items.First() as Product; var index = GridData.FindIndex(i => i.Id == item.Id); if (index != -1) @@ -88,7 +88,7 @@ How to dynamically set the Grid popup edit Window title? private void OnGridCreate(GridCommandEventArgs args) { - var item = args.Item as Product; + var item = args.Items.First() as Product; item.Id = GridData.Count + 1; diff --git a/knowledge-base/grid-row-template-simulate-built-in-functions.md b/knowledge-base/grid-row-template-simulate-built-in-functions.md index f226562fcb..be5a219755 100644 --- a/knowledge-base/grid-row-template-simulate-built-in-functions.md +++ b/knowledge-base/grid-row-template-simulate-built-in-functions.md @@ -202,7 +202,7 @@ To implement a custom command column: private void OnCreateHandler(GridCommandEventArgs args) { - var createdItem = (ArticleDto)args.Item; + var createdItem = (ArticleDto)args.Items.First(); createdItem.Id = Guid.NewGuid(); var rnd = new Random(); createdItem.ImageUrl = $"https://demos.telerik.com/blazor-ui/images/photos/{rnd.Next(1, 30) % 7 + 1}.jpg"; @@ -226,7 +226,7 @@ To implement a custom command column: private void OnUpdateHandler(GridCommandEventArgs args) { - var updatedItem = (ArticleDto)args.Item; + var updatedItem = (ArticleDto)args.Items.First(); var index = GridData.FindIndex(i => i.Id == updatedItem.Id); if (index != -1) { diff --git a/knowledge-base/grid-select-on-incell-edit.md b/knowledge-base/grid-select-on-incell-edit.md index e09bc7f2dc..184b2b9bd0 100644 --- a/knowledge-base/grid-select-on-incell-edit.md +++ b/knowledge-base/grid-select-on-incell-edit.md @@ -93,7 +93,7 @@ Use the [Grid events](slug:grid-events#cud-events) to update the `SelectedItems` public void EditHandler(GridCommandEventArgs args) { - var item = args.Item as Product; + var item = args.Items.First() as Product; AddToSelectedCollection(item); } @@ -111,7 +111,7 @@ Use the [Grid events](slug:grid-events#cud-events) to update the `SelectedItems` public void UpdateItem(GridCommandEventArgs args) { - var item = args.Item as Product; + var item = args.Items.First() as Product; int index = GridData.FindIndex(x => item.ProductId == x.ProductId); var currentSelectedItems = new List(SelectedItems); int selectedItemIndex = currentSelectedItems.FindIndex(x => x.ProductId == item.ProductId); @@ -209,7 +209,7 @@ Use the [Grid events](slug:grid-events#cud-events) to update the `SelectedItems` @code { public void EditHandler(GridCommandEventArgs args) { - var item = args.Item as Product; + var item = args.Items.First() as Product; AddToSelectedCollection(item); } @@ -227,7 +227,7 @@ Use the [Grid events](slug:grid-events#cud-events) to update the `SelectedItems` public void UpdateItem(GridCommandEventArgs args) { - var item = args.Item as Product; + var item = args.Items.First() as Product; int index = GridData.FindIndex(x => item.ProductId == x.ProductId); var currentSelectedItems = new List(SelectedItems); int selectedItemIndex = currentSelectedItems.FindIndex(x => x.ProductId == item.ProductId); diff --git a/knowledge-base/grid-transposed.md b/knowledge-base/grid-transposed.md index 348aaf2339..5d970576eb 100644 --- a/knowledge-base/grid-transposed.md +++ b/knowledge-base/grid-transposed.md @@ -238,7 +238,7 @@ The following example demonstrates all options. private void OnGridUpdate(GridCommandEventArgs args) { - var updatedItem = (GridItem)args.Item; + var updatedItem = (GridItem)args.Items.First(); DataItem.Active = updatedItem.Active; DataItem.Description = updatedItem.Description; diff --git a/knowledge-base/grids-foreign-key.md b/knowledge-base/grids-foreign-key.md index 12f7a7c703..6255248adb 100644 --- a/knowledge-base/grids-foreign-key.md +++ b/knowledge-base/grids-foreign-key.md @@ -296,7 +296,7 @@ There are a few ways to implement the scenario: private async Task OnGridUpdate(GridCommandEventArgs args) { - Product updatedItem = (Product)args.Item; + Product updatedItem = (Product)args.Items.First(); int indexToUpdate = Products.FindIndex(x => x.Id == updatedItem.Id); if (indexToUpdate != -1) { @@ -307,14 +307,14 @@ There are a few ways to implement the scenario: private async Task OnGridCreate(GridCommandEventArgs args) { - Product createdItem = (Product)args.Item; + Product createdItem = (Product)args.Items.First(); await Task.Delay(100); // simulate async operation Products.Insert(0, createdItem); } private async Task OnGridDelete(GridCommandEventArgs args) { - Product itemToDelete = (Product)args.Item; + Product itemToDelete = (Product)args.Items.First(); await Task.Delay(100); // simulate async operation Products.Remove(Products.First(x => x.Id == itemToDelete.Id)); } diff --git a/knowledge-base/treelist-add-edit-state.md b/knowledge-base/treelist-add-edit-state.md index 566efb1cb4..76f137e570 100644 --- a/knowledge-base/treelist-add-edit-state.md +++ b/knowledge-base/treelist-add-edit-state.md @@ -292,7 +292,7 @@ All these operations can also be used for [`Incell`](slug:treelist-editing-incel private async Task OnTreeListInlineCreate(TreeListCommandEventArgs args) { - var createdItem = (Employee)args.Item; + var createdItem = (Employee)args.Items.First(); var parentItem = (Employee?)args.ParentItem; await TreeListEmployeeInlineService.Create(createdItem, parentItem); @@ -302,7 +302,7 @@ All these operations can also be used for [`Incell`](slug:treelist-editing-incel private async Task OnTreeListInlineUpdate(TreeListCommandEventArgs args) { - var updatedItem = (Employee)args.Item; + var updatedItem = (Employee)args.Items.First(); await TreeListEmployeeInlineService.Update(updatedItem); @@ -315,7 +315,7 @@ All these operations can also be used for [`Incell`](slug:treelist-editing-incel private async Task OnTreeListIncellCreate(TreeListCommandEventArgs args) { - var createdItem = (Employee)args.Item; + var createdItem = (Employee)args.Items.First(); var parentItem = (Employee?)args.ParentItem; await TreeListEmployeeIncellService.Create(createdItem, parentItem); @@ -325,7 +325,7 @@ All these operations can also be used for [`Incell`](slug:treelist-editing-incel private async Task OnTreeListIncellUpdate(TreeListCommandEventArgs args) { - var updatedItem = (Employee)args.Item; + var updatedItem = (Employee)args.Items.First(); await TreeListEmployeeIncellService.Update(updatedItem); diff --git a/knowledge-base/treelist-enable-checkbox-selection-only-edit-mode.md b/knowledge-base/treelist-enable-checkbox-selection-only-edit-mode.md index 8be36fe0f4..a7c3d565dc 100644 --- a/knowledge-base/treelist-enable-checkbox-selection-only-edit-mode.md +++ b/knowledge-base/treelist-enable-checkbox-selection-only-edit-mode.md @@ -91,7 +91,7 @@ Below is an example implementation that toggles the visibility of the Checkbox C #region CUD operations private async Task UpdateItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; await MyService.Update(item); @@ -103,7 +103,7 @@ Below is an example implementation that toggles the visibility of the Checkbox C private async Task CreateItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; var parentItem = args.ParentItem as Employee; await MyService.Create(item, parentItem); @@ -116,7 +116,7 @@ Below is an example implementation that toggles the visibility of the Checkbox C private async Task DeleteItem(TreeListCommandEventArgs args) { - var item = args.Item as Employee; + var item = args.Items.First() as Employee; await MyService.Delete(item); @@ -128,7 +128,7 @@ Below is an example implementation that toggles the visibility of the Checkbox C //Show CheckboxColumn SelectionEnabled = true; - Employee empl = args.Item as Employee; + Employee empl = args.Items.First() as Employee; //Check if the item is already selected, so you do not clear its selection in the OnCancel if (SelectedItems.Any(x => x.Id == empl.Id)) @@ -149,7 +149,7 @@ Below is an example implementation that toggles the visibility of the Checkbox C private async Task OnCancelHandler(TreeListCommandEventArgs args) { - Employee empl = args.Item as Employee; + Employee empl = args.Items.First() as Employee; //Check if the user selected the item during the last edit and cancel it. Leave the selection if the item was previously selected if (!ItemAlreadySelected && SelectedItems.Any(x => x.Id == empl.Id)) diff --git a/knowledge-base/upload-files-in-grid.md b/knowledge-base/upload-files-in-grid.md index a0022e2119..8cdf35409f 100644 --- a/knowledge-base/upload-files-in-grid.md +++ b/knowledge-base/upload-files-in-grid.md @@ -176,7 +176,7 @@ The tabs below show a possible implementation for the Razor UI, `Save` and `Remo { await Task.Delay(1); // simulate network delay - var updatedItem = (Product)args.Item; + var updatedItem = (Product)args.Items.First(); var originalItemIndex = GridData.FindIndex(x => x.Id == updatedItem.Id); if (originalItemIndex >= 0) { @@ -188,7 +188,7 @@ The tabs below show a possible implementation for the Razor UI, `Save` and `Remo { await Task.Delay(100); // simulate network delay - var addedItem = (Product)args.Item; + var addedItem = (Product)args.Items.First(); addedItem.Id = ++LastId; } @@ -197,14 +197,14 @@ The tabs below show a possible implementation for the Razor UI, `Save` and `Remo { await Task.Delay(100); // simulate network delay - var createdItem = (Product)args.Item; + var createdItem = (Product)args.Items.First(); GridData.Insert(0, createdItem); } private async Task OnGridDelete(GridCommandEventArgs args) { - var itemToDelete = (Product)args.Item; + var itemToDelete = (Product)args.Items.First(); var originalItemIndex = GridData.FindIndex(x => x.Id == itemToDelete.Id); if (originalItemIndex >= 0) { diff --git a/knowledge-base/validation-custom-dataannotations-validator.md b/knowledge-base/validation-custom-dataannotations-validator.md index b81ff96183..3ab293e455 100644 --- a/knowledge-base/validation-custom-dataannotations-validator.md +++ b/knowledge-base/validation-custom-dataannotations-validator.md @@ -113,7 +113,7 @@ This KB answers the following questions: private void OnGridCreate(GridCommandEventArgs args) { - var createdItem = (OrderDelivery)args.Item; + var createdItem = (OrderDelivery)args.Items.First(); createdItem.Id = ++LastId; @@ -122,7 +122,7 @@ This KB answers the following questions: private void OnGridUpdate(GridCommandEventArgs args) { - var updatedItem = (OrderDelivery)args.Item; + var updatedItem = (OrderDelivery)args.Items.First(); var originalItemIndex = GridData.FindIndex(i => i.Id == updatedItem.Id); if (originalItemIndex != -1)