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

other cell values in the same row

We are testing to introduce syncfusion. A new row was added. 1. Modify column number 1. 2. When modifying the value of column 2, I use the column value of column 1 and column 2 as parameters to retrieve the value from the database and put the value in column 3. Q. What I want to know is how to get the value of column 1 in the event that is executed after changing the value of column 2 and how to put the value in column 3. (It seems simple... but it doesn't work.) Thank you.


1 Reply

SP Sarveswaran Palani Syncfusion Team December 19, 2022 03:42 AM UTC

Hi Junghwi,

Greetings from Syncfusion support.

We have analyzed your query and suggest you to change the values for a datagrid column based on other column values by using the context parameter in the Template property of the GridColumn component. Refer the attached code snippet and documentation link for your reference.


<GridColumn Field=@nameof(Order.ManfCost) HeaderText="Manufacturing Cost" Format="C2" TextAlign="TextAlign.Center" Width="120"></GridColumn>

        <GridColumn Field=@nameof(Order.LabCost) HeaderText="Labor Cost" Format="C2" TextAlign="TextAlign.Center" Width="120"></GridColumn>

        <GridColumn Field=@nameof(Order.FinalCost) HeaderText="Final price" Format="C2" TextAlign="TextAlign.Center" Width="120">

            <Template>

                @{

                    var value = (context as Order);

                    var finalAmount = value.ManfCost + value.LabCost;

                    <div>$@finalAmount</div>

                }

            </Template>

        </GridColumn>


Reference: https://blazor.syncfusion.com/documentation/datagrid/how-to/calculate-column-value-based-on-other-columns


Regards,

Sarveswaran PK


Loader.
Live Chat Icon For mobile
Up arrow icon