Force row to stay in edit mode (after saving)

Hello, 
I created a grid inline with a custom adapter.
In some case, I want the edited row to stay in Edit mode.

I would like to know if it is possible to force the grid to stay in edit mode, in  a insert/update method in my custom adpater?
If not how can i acheive that?
Thank you

3 Replies 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team March 18, 2021 08:45 AM UTC

Hi Audrey, 

Greetings from Syncfusion support. 

You can prevent the Save action in Grid by cancelling the save in OnActionBegin event of Grid, based on your scenario. In the below code, based on the RequestType as Save and based on the value entered for the CustomerID column as “DontSave”, we have prevented the save action. So now the edit form will be remained open when DontSave value is entered as CustomerID column field value. 

Please refer and use like the codes below, 

<SfGrid @ref="Grid" TValue="Order" ...>    <GridEvents OnActionBegin="OnActionBegin" TValue="Order"></GridEvents>    ...</SfGrid>
 
public async Task OnActionBegin(ActionEventArgs<Order> args) 
{ 
    if (args.RequestType.Equals(Action.Save) && args.Data.CustomerID == "DontSave") 
    { 
        args.Cancel = true;     //prevent the save action
    } 
} 



Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 



PS psyk March 18, 2021 03:41 PM UTC

Hello, 
thank you for the anwers.
But, if I cancel  the save action, I dont think it will call the insert/update method of my customadapter?
I want to save, but i want my saved row to (sometimes) stay in edit mode. Is it possible?
Thank you


RS Renjith Singh Rajendran Syncfusion Team March 19, 2021 02:52 AM UTC

Hi Audrey, 

We suggest you to programmatically enable editing for the particular row by using the StartEdit method of Grid in OnActionComplete event. Based on the RequestType we have programmatically selected and edited the row. Please refer the codes below, 

 
<GridEvents OnActionComplete="OnActionComplete" TValue="Order"></GridEvents> 
public async Task OnActionComplete(ActionEventArgs<Order> args){    if (args.RequestType.Equals(Action.Save))    {        await Task.Yield();        var index = await Grid.GetRowIndexByPrimaryKey(args.Data.OrderID);        await Grid.SelectRow(index);        await Grid.StartEdit();    }}


Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Marked as answer
Loader.
Up arrow icon