How to modify data object before dialog is displayed

My solution is using .net core 7 and syncfusion 22.1.37.

I am using a data grid with dialog edit mode. 

After the user click on edit button or double clicks row, i want to modify the data object. I need to set some default values based on who is logged into the application.

i tried using Action.BeforeBeginEdit and setting 

Args.Data.Company = "true";

but the dialog did not reflect the change


1 Reply

SB Sweatha Bharathi Syncfusion Team July 7, 2023 05:12 AM UTC


Hi Barry,

Query:” Click on edit button or double clicks row, i want to modify data object before dialog is displayed”

Based on your query, we recommend using the OnActionComplete event. This event allows you to modify the data object before the dialog is displayed, specifically when using the data request type "BeginEdit." We have provided a code snippet and a sample for your reference below.

 

<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" Height="315">

    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Dialog"></GridEditSettings>

    <GridEvents OnActionBegin="ActionBegin" TValue="Order"></GridEvents>

</SfGrid>

 

@code {

    public List<Order> Orders { get; set; }

 

 

    public void ActionBegin(ActionEventArgs<Order> args)

    {

 

        if (args.RequestType == Syncfusion.Blazor.Grids.Action.BeginEdit)

        {

            args.Data.CustomerID = "CustomerName";

        }

 

    }

 

 

}


A screenshot of a computer

Description automatically generated



Documentation: Editing in Blazor DataGrid Component | Syncfusion

Regards,
Prathap S


Attachment: DataGrid_3693593d.zip

Loader.
Up arrow icon