Hi,
I'm using a Sfgrid in edit mode, my idea is to use the command column to edit the values of a specific row. Once I click on the Command Column Edit button, I manage to update the values of the row, but when I click on save and the OnCommandClicked event is triggered, I don't get the updated values in the args.RowData, but the original values of the datasource.
Please find the code attached for reference (SfGrid and OnCommandClicked method).
Is there something I am missing to have the values binded?
Thanks.
|
<SfGrid DataSource="@Orders" AllowPaging="true" Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridEvents OnActionBegin="ActionBeginHandler" CommandClicked="OnCommandClicked" TValue="Order"></GridEvents>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
. . .
<GridColumn HeaderText="Manage Records" Width="150">
<GridCommandColumns>
<GridCommandColumn Type="CommandButtonType.Edit" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-edit", CssClass = "e-flat" })"></GridCommandColumn>
<GridCommandColumn Type="CommandButtonType.Delete" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-delete", CssClass = "e-flat" })"></GridCommandColumn>
<GridCommandColumn Type="CommandButtonType.Save" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-update", CssClass = "e-flat" })"></GridCommandColumn>
<GridCommandColumn Type="CommandButtonType.Cancel" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-cancel-icon", CssClass = "e-flat" })"></GridCommandColumn>
</GridCommandColumns>
</GridColumn>
</GridColumns>
</SfGrid>
@code{
public List<Order> Orders { get; set; }
. ..
public void OnCommandClicked(CommandClickEventArgs<Order> args)
{
// Perform required operations here
}
public void ActionBeginHandler(ActionEventArgs<Order> args)
{
if(args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Save))
{
var editedData = args.Data; //you can get the updated data using args.Data
}
// Here you can customize your code
}
} |
Hi Rahul,
thanks for your answer, it is working now.
Thanks,
M