How to set row value in list when some changes in grid

I have an sfgrid in "Dialogue Mode".I would like to know how to update list when new row are added or some changes in grid row (update). 

For example 

I have an "Active" Column in list. I would like to make as "1" when there is some changes in grid. 

5 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team June 14, 2021 04:24 AM UTC

Hi Hassan,  
 
Greetings from Syncfusion support.  
 
Query: “I have an "Active" Column in list. I would like to make as "1" when there is some changes in grid 
 
We have validated query and we are quite unclear about your requirement. We need some more details about your requirement. So kindly share the following details.  
 
  1. Do you want to update another column value while updating one column?
  2. When do you want to update the value (i.e.) while selecting the value itself or while saving the changes in Grid?.
  3. Do you want to change the value when edit dialog is visible?
  4. Are you referring to Cascading dropdown list in dialog editing. If yes, refer the below documentation link
  1. Share more details about your requirement.
 
Above details will be very helpful for us to understand your requirement and provide a better solution as early as possible.  
 
Regards, 
Vignesh Natarajan  
 



KI KINS June 14, 2021 01:30 PM UTC

Yes the second point is my requirement.

" while saving the changes in Grid?"


VN Vignesh Natarajan Syncfusion Team June 15, 2021 04:11 AM UTC

Hi Hassan,  
 
Thanks for the confirmation.  
 
Query: ” while saving the changes in Grid?" 
 
We have analyzed your query and we suggest you to achieve your requirement using OnActionBegin event of the Grid. OnActionComplete event will be triggered when certain action gets initiated. So while saving the changes in Grid, OnActionBegin event will be triggered with a RequestType as Save. Here we suggest you change row data for Action column using the event arguments.  
 
Refer the below code example.  
 
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add""Edit""Delete""Update""Cancel" })" Height="315"> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Dialog"></GridEditSettings> 
    <GridEvents OnActionBegin="ActionBeginHandler" TValue="Order"></GridEvents> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" ValidationRules="@(new ValidationRules{ Required=true})" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" ValidationRules="@(new ValidationRules{ Required=true})" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.Active) AllowEditing="false" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" EditType="EditType.DatePickerEdit" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" EditType="EditType.NumericEdit" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.ShipCountry) HeaderText="Ship Country" EditType="EditType.DropDownEdit" Width="150"></GridColumn> 
    </GridColumns> 
</SfGrid> 
  
@code{ 
    public List<Order> Orders { getset; } 
  
    public void ActionBeginHandler(ActionEventArgs<Order> Args) 
    { 
        if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save) 
        { 
            //to differentitate the add and edit operation. since for both action Save will be sent 
            if (Args.Action == "Edit") 
            { 
                //update in Data variable to reflect in grid data. 
                Args.Data.Active = 1; 
            } 
        } 
    } 
 
 
for your convenience we have attached the sample which can be downloaded from below  
 
 
Refer our UG documentation for your reference 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 


Marked as answer

KI KINS June 15, 2021 03:12 PM UTC

Fine...

Got it....


VN Vignesh Natarajan Syncfusion Team June 16, 2021 03:36 AM UTC

Hi Hassan, 

Thanks for the update.  

We are glad to hear that you have achieved your requirement using our solution.  

Please get back to us if you have further queries.  

Regards, 
Vignesh Natarajan

Loader.
Up arrow icon