How to get index of a newly added row to fill custom values to specific columns.

Is there a way to fill values programmatically based on an X column (value is used to get info from the API and fill to their respective columns) on the newly added row in batch mode?

Or a way to add values to a specific column in the grid on the newly added row(in batch mode not yet saved.)


1 Reply

SP Sarveswaran Palani Syncfusion Team February 15, 2023 01:01 PM UTC

Hi Royland,

Greetings from Syncfusion support.

From your query, we suspect that in batch edit mode you want to change the column value based on another column value. We have prepared sample based on your requirement. Kindly refer the attached code snippet and shared sample for your reference.

<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })">

    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"> </GridEditSettings>

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

            <Template>

                @{
                   
//you can customize value based on your requirement

                    var value = (context as Order);

                    var finalAmount = value.ManfCost + value.LabCost;

                    <div>$@finalAmount</div>

                }

            </Template>

        </GridColumn>
</
SfGrid>


Please get back to us if you have any question or concern.

Regards,
Sarvesh


Attachment: SfGrid_ValueChange_d70f4779.zip

Loader.
Up arrow icon