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?
|
<GridEvents OnActionComplete="OnActionComplete" OnActionBegin="OnActionBegin" TValue="SysArea"></GridEvents>
...
<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>
<EditTemplate>
<SfTextBox ID="Name" Value=@NameValue></SfTextBox>
</EditTemplate>
</GridColumn>
<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;
}
}
|
this solution work with last version