I want to set the edit mode of DataGrid differently between Add and Edit.

Hello.
I can select Inline or Dialog etc depending on DataGrid's EditMode.
I wonder if this is possible.
Add is in Dialog Edit mode,
Edit is in Inline Edit mode
Is this possible?
Thank you.

1 Reply 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team August 10, 2020 11:31 AM UTC

Hi Seil, 

Greetings from Syncfusion support. 

We suggest you to set property binding for the Mode property of GridEditSettings to achieve this requirement. In the below code, we have modified the Mode property value dynamically based on the RequestType in the OnActionBegin handler. Please refer and use as like the below code, 

 
<SfGrid @ref="Grid" DataSource="@Orders" ...> 
    <GridEvents OnActionBegin="OnActionBegin" TValue="Order"></GridEvents> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="@EditModeSelection" ></GridEditSettings> 
    ... 
</SfGrid> 
 
@code{ 
    SfGrid<Order> Grid; 
    EditMode EditModeSelection { getset; } 
    public List<Order> Orders { getset; } 
 
    public void OnActionBegin(ActionEventArgs<Order> args) 
    { 
        if (args.RequestType.ToString() == "Add") 
        { 
            EditModeSelection = EditMode.Dialog; 
        } 
        if (args.RequestType.ToString() == "BeginEdit") 
        { 
            EditModeSelection = EditMode.Normal; 
        } 
    } 
    ... 
} 


We have also prepared a sample based on this scenario. Please download the sample from the link below, 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Marked as answer
Loader.
Up arrow icon