<SfButton
OnClick="@Enable">EnableEdit</SfButton>
<SfGrid DataSource="@Orders"
@ref="Grid" AllowPaging="true" Toolbar=@ToolbarItems
Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="@Allowedit"
AllowDeleting="true"
Mode="EditMode.Batch"></GridEditSettings>
&&
private List<object> ToolbarItems = new
List<object>() {
new ItemModel()
{ Text = "Add Record", PrefixIcon = "e-add", Id =
"Grid_add"},//Here Grid is SfGrid ID
new
ItemModel(){ Text = "Edit Record", PrefixIcon= "e-edit",
Id="Grid_edit"},
new
ItemModel(){ Text = "Delete Record", PrefixIcon=
"e-delete", Id="Grid_delete"},
new
ItemModel(){ Text = "Update Record", PrefixIcon=
"e-update", Id="Grid_update"},
new
ItemModel(){ Text = "Cancel Changes", PrefixIcon=
"e-cancel", Id="Grid_cancel"},
};
public bool Allowedit = false;
public void Enable()
{
Allowedit = true;
}
public void
ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
if
(args.Item.Text == "Update Record")
{
Grid.EndEditAsync();
}
if
(args.Item.Text == "Delete Record")
{
Grid.DeleteRecordAsync();
}
if
(args.Item.Text == "Cancel Changes")
{
Grid.CloseEditAsync();
}
}
|