Bug/Issue when using an EditTemplate witht the context variable within a grid

Hello,

I am experiencing an issue in SfGrid in which I have need for an EditTemplate - 

After (a lot) of debugging I have come to the conclusion that the "context" variable which should be used by a control (in my case a Combobox, but for simplicity I have reproduced this issue in a simple SfTextBox) is in fact the actual underlying object from the data source in stead of a copy.

I expect that if I put the grid in edit mode and alter some values and then Escape / cancel these changes - the underlying data is not changed. For the default editors this is indeed the case. But when using an EditTemplate the changes are persistent in the data source. To make matters worse - this is not shown in the grid itself. 

Consider the following: (EDIT - i cannot paste .razor contents - I will attach the .razor / .cs file)

Steps:

  1. Instantiate this component
  2. Double click on a cell 
  3. and change the right most columns (2 and 3)
  4. Press escape - at this time I observe a CTOR console line - I think this is weird and expected that at step 2, but no issue there.
  5. In the grid the changes made in step 3 appear reverted - but as shown in the @foreach (var rec in _data) - the actual data is indeed changed.


2 Replies

RI richardv May 19, 2020 02:24 PM UTC

Reproduction of the issue attached

Attachment: TestNS_c987660e.7z


RS Renjith Singh Rajendran Syncfusion Team May 20, 2020 09:10 AM UTC

Hi Richard, 

Greetings from Syncfusion support. 

By default, when pressing the escape will cancel the edit changes made in the edit form from updating into Grid. So the value entered in SfTextBox will not be updated to Grid(this is why Grid not show the modified value). 

And based on your scenario, it is recommended to use the Value property of SfTextBox instead of @bind-Value property. Please refer the code below, 

 
<GridColumn Field=@nameof(TestRecord.Col3) HeaderText="3"> 
    <EditTemplate> 
        <Syncfusion.Blazor.Inputs.SfTextBox ID="Col3" Value="@((context as TestRecord).Col3)" /> 
    </EditTemplate> 
</GridColumn> 


And also ensure to set the ID property value for the SfTextBox same as that of the Field name value, to update the value into Grid. 

We have also prepared a modified sample based on your scenario. Please download the sample form the link below, 
 
Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Loader.
Up arrow icon