We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Set Complex column Value in CellSaved Event

hi

I have complex column that contains an additional field IsInEdit

I want when the value of cell changes , IsInEdit property set value to true

thank you





Attachment: BlazorApp1_fc3803fc.zip

4 Replies

MS Monisha Saravanan Syncfusion Team October 19, 2022 09:48 AM


Hi Ali,


Greetings from Syncfusion support.


Query: “I have complex column that contains an additional field IsInEdit. I want when the value of cell changes , IsInEdit property set value to true”


We have checked your query and we suspect that you need to change the complex column value when the cell is edited. Instead of updating the values in CellSaved event we suggest you to make changes in OnBatchSave event. Because if an changed record is replaced with old value at that time the Boolean value will be incorrect. But OnBatchSave event will be triggered at the time of saving the record to the DataSource.


Also we can change the complex column variable by getting the instance from the argument and there is no other possible ways in updating the complex column value. Kindly refer the attached code snippet for your reference.


Reference: https://blazor.syncfusion.com/documentation/datagrid/events#onbatchsave



   <SfGrid @ref="Grid"

               AllowResizing="true" AllowTextWrap="true" AllowSelection="true"

                GridLines="GridLine.Both"

                AllowPaging="true"

                Height="100%"

             

                DataSource="@Productions"

                Toolbar="@(new List<string>() {"Add", "Update", "Cancel"})">

            <GridEvents

               OnBatchSave="BatchSave"

                CellSaved="OnCellSavedHandler"

            

                TValue="ProductionViewModel">

            </GridEvents>

            <GridPageSettings PageSize="24"></GridPageSettings>

     

    

      

        </SfGrid>

       

 

 

@code {

    private void BatchSave(BeforeBatchSaveArgs<ProductionViewModel> arg)

    {

        var changedrec = arg.BatchChanges.ChangedRecords;

        if(changedrec != null)

        {

            changedrec[0].P1.Pressure.IsInEdit = true;

            changedrec[0].P1.Rate.IsInEdit = true;

            // Similarly we suggets you to handle the same for p2, p3,p4

        }

       

    }

 

}

 



Please let us know if you have any concerns.


Regards,

Monisha



AL ali October 20, 2022 01:55 AM

hi

thank you

in project 30 fields "P" There is

Each user must have access to some fields

For example,

user X to the columns p1,p2,p4,p7

user X to the columns p3,p5,p6,p8

and etc

by reflection I recover them

and convert complex columns "p" to rows

A problem that exists

All 30 fields are converted into rows for registration

But I want to convert fields to rows whose values have changed in the grid, not all fields.




AL ali October 20, 2022 01:58 AM

I edited and sent the codes

Thank you for solve my problem


Attachment: BlazorApp1_dedaa16.zip


MS Monisha Saravanan Syncfusion Team October 20, 2022 07:03 AM

Hi Ali,


Thanks for the update.


Query: “But I want to convert fields to rows whose values have changed in the grid, not all fields.”


We suspect that you need to make changes in the changed field values. If so we suggest you to use GetBatchChanges method of DataGrid. It will contain the changes record details and we can make changes to the corresponding changed field only by using this method.


Please let us know if you have any concerns.


Regards,

Monisha


Loader.
Live Chat Icon For mobile
Up arrow icon