Modify the value of a cell while another cell is being edited in normal mode

Hi,

Im trying to edit a numeric field of a grid and that should modify (in real time) the value of another field of the same grid without saving the changes, but it only works when saving. I want to use the "Normal" or "Inline" edit mode. I tried to apply this solution: https://www.syncfusion.com/forums/151238/edit-one-column-update-the-value-in-another-column but I'm not using EJ2 so it doesn't work in my case. 

In the example below, when editing the "Com Base C1" field, the value of the "%Ctrb. Mg C1" field should be altered while editing "Com Base C1"


Can you guys provide me some answer here?


2 Replies

RS Renjith Singh Rajendran Syncfusion Team January 18, 2022 12:14 PM UTC

Hi Claudio, 
 
Greetings from Syncfusion support. 
 
Based on your requirement of updating other field values in edit form based on value change in a particular field, we have prepared a sample. Please download and refer the sample from the link below, 
 
In the above sample, changing the SiteId value from dropdown in edit form will modify the values available in Name and Description fields. Please refer the above sample and update your application based on the suggestion. 
 
We have achieved this requirement by using the EditTemplate feature of Grid. And used ValueChange event of SfDropDownList and the OnActionBegin and OnActionComplete events of Grid.  
References :  
 
Please refer the codes below, 
 
 
    <GridEvents OnActionComplete="OnActionComplete" OnActionBegin="OnActionBegin" TValue="SysArea"></GridEvents> 
    ... 
        <GridColumn MinWidth="50" Field=@nameof(SysArea.SiteId) TextAlign="TextAlign.Left"> 
            <EditTemplate> 
                @{ 
                    var a = context as SysArea; 
                } 
                <SfDropDownList ID="SiteId" TItem="long?" TValue="long?" @bind-Value="@((context as SysArea).SiteId)" DataSource="@Countries"> 
                    <DropDownListEvents ValueChange="ValueChange" TItem="long?" TValue="long?" ></DropDownListEvents> 
                </SfDropDownList> 
            </EditTemplate> 
        </GridColumn> 
        <GridColumn MinWidth="50" Field=@nameof(SysArea.Name) TextAlign="TextAlign.Left"> 
            <EditTemplate> 
                <SfTextBox ID="Name" Value=@NameValue></SfTextBox> 
            </EditTemplate> 
        </GridColumn> 
        <GridColumn MinWidth="50" Field=@nameof(SysArea.Description) TextAlign="TextAlign.Left"> 
            <EditTemplate> 
                <SfTextBox ID="Description" Value=@DescriptionValue></SfTextBox> 
            </EditTemplate> 
        </GridColumn> 
 
    public string NameValue {get;set;} 
    public string DescriptionValue {get;set;} 
    ... 
    public List<long?> Countries = new List<long?>() { 1, 2, 3, 4, 5  }; 
    public void OnActionComplete(ActionEventArgs<SysArea> args) 
    { 
        if (args.RequestType.Equals(Action.Add) || args.RequestType.Equals(Action.BeginEdit)) 
        { 
            //based on Add or Edit action disable the PreventRender 
            args.PreventRender = false; 
        } 
    } 
    public void OnActionBegin(ActionEventArgs<SysArea> args) 
    { 
        if (args.RequestType.Equals(Action.Add) || args.RequestType.Equals(Action.BeginEdit)) 
        { 
            //update the values to Name and Description fields on edit form opening   
            NameValue = args.Data.Name; 
            DescriptionValue = args.Data.Description; 
        } 
        if (args.RequestType.Equals(Action.Save)) 
        { 
            //update the values of Name and Description fields in grid based on values from edit form 
            args.Data.Name = NameValue; 
            args.Data.Description = DescriptionValue; 
        } 
    } 
 
    public void ValueChange(ChangeEventArgs<long?,long?> args) 
    { 
        //change the values in Name and Description fields based on the dropdown selection 
        if(args.Value == 1 || args.Value == 2) 
        { 
            NameValue = "Name value based on" + args.Value; 
            DescriptionValue = "Description value based on" + args.Value; 
        } 
        else 
        {    
            NameValue = "Name value based on" + args.Value; 
            DescriptionValue = "Description value based on" + args.Value; 
        } 
    } 

 
Please get back to us if you need further assistance. 
 
Regards, 
Renjith R 



AD Andrea Del Signore July 5, 2022 08:19 AM UTC

this solution  work with last version


Loader.
Up arrow icon