...
<EjsGrid @ref=this.defaultGrid DataSource=@this.gridData ShowColumnChooser="true" Toolbar="@(new List<string>() { "ColumnChooser", "Search" })"
AllowFiltering="true" CommandClicked="@CommandClickHandler">
<GridFilterSettings Type="@Syncfusion.EJ2.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
<GridSearchSettings Fields="@search" Operator="contains" Key="Denmark" IgnoreCase="true"></GridSearchSettings>
<GridColumns>
...
<GridColumn HeaderText="Actions" Commands=commands></GridColumn>
</GridColumns>
</EjsGrid>
@functions{
...
protected override async Task OnInitAsync()
{
await base.OnInitAsync();
this.commands.Add(new CommandModel { Type = CommandButtonType.Delete, Title = "Delete", ButtonOption = new CommandButtonOptions { IconCss = "e-btn-sb-icons e-open-icon", CssClass = "e-small e-round" } });
this.commands.Add(new CommandModel { Type= CommandButtonType.Edit,Title = "Edit", ButtonOption = new CommandButtonOptions { IconCss = "e-btn-sb-icons e-add-icon", CssClass = "e-small e-round" } });
this.gridData = OrdersDetails.GetAllRecords();
}
public void CommandClickHandler(CommandClickEventArgs args)
{
var selectedId = JsonConvert.DeserializeObject<OrdersDetails>(args.RowData.ToString()).OrderID;
switch (args.CommandColumn.Title)
{
case "Edit":
IsModalShown = true;
this.Invoke(this.StateHasChanged);
break;
case "Delete":
this.DeleteCategory(selectedId);
break;
}
}
...
} |