Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions _contentTemplates/grid/editing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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";
}

Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions _contentTemplates/treelist/editing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion common-features/loading-sign.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions components/grid/accessibility/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions components/grid/columns/auto-generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions components/grid/columns/command.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
{
Expand All @@ -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("<br />Custom command triggered for item {0}", (args.Item as SampleData).ID));
CustomCommandResult = new MarkupString(CustomCommandResult + string.Format("<br />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");

Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions components/grid/columns/stacked.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions components/grid/data-binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion components/grid/editing/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<object>` | 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
Expand Down
4 changes: 2 additions & 2 deletions components/grid/editing/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand Down
24 changes: 12 additions & 12 deletions components/grid/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);
Expand All @@ -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()
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);
Expand All @@ -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()
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions components/grid/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,15 @@ 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;
}

private void OnGridCreate(GridCommandEventArgs args)
{
var createdItem = (Product)args.Item;
var createdItem = (Product)args.Items.First();

GridData.Insert(0, createdItem);
}
Expand Down
2 changes: 1 addition & 1 deletion components/grid/templates/command-column-header.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Loading
Loading