change default action of clicking in grid

I have a SfGrid which lives in a SfDataForm:

       <FormItem Field="@nameof(_newSolutionModel.ChemicalAdded)" ID="xxx" ColumnSpan="6">

           <Template>

               <label class="e-form-label">Select Ingredients</label>



               <SfGrid @ref="_ingrGrid" DataSource="@EditedIngredients" AllowSelection="true" Height="200px"

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

                   <GridKeySettings MoveDownCell="ArrowDown"></GridKeySettings>


                   <GridEditSettings AllowAdding="true" AllowEditing="true" Mode="EditMode.Normal" AllowDeleting="true" NewRowPosition="NewRowPosition.Bottom"/>


                   <GridEvents TValue="EditedIngredient" OnActionBegin="ActionBeginHandler" OnActionComplete="ActionCompleteHandler" ></GridEvents>


                   <GridColumns>


                       <GridColumn Index="1" Field=@nameof(EditedIngredient.Id) HeaderText="ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="60"

                                   Visible="false">

                       </GridColumn>


                       <GridColumn Field="ChemOrSolText" HeaderText="Toggle" EditType="EditType.DropDownEdit" Width="10%">

                           <EditTemplate>

                               @if (context is EditedIngredient editedIngredient)

                               {

                                   <SfDropDownList TValue="string" TItem="toggleItem" Placeholder="Select" DataSource="@toggleList"

                                                   Enabled="true" @bind-Value="@editedIngredient.ChemOrSolText">

                                       <DropDownListEvents TValue="string" TItem="toggleItem" OnValueSelect="OnCoSSelect"></DropDownListEvents>

                                       <DropDownListFieldSettings Text="ChemOrSolText" Value="ChemOrSolText"></DropDownListFieldSettings>

                                   </SfDropDownList>

                               }


                           </EditTemplate>

                       </GridColumn>


                       <GridColumn Field="Item" HeaderText="Item" EditType="EditType.DropDownEdit" Width="18%">

                           <EditTemplate>


                               @if (context is EditedIngredient editedIngredient)

                               {

                                   <SfDropDownList @ref="DDLItem" TValue="string" TItem="EditedIngredient" Placeholder="@PlaceholderF02" DataSource="@FilteredItems"

                                                   @bind-Value="@editedIngredient.Item" Enabled="@(!string.IsNullOrEmpty(editedIngredient.ChemOrSolText))">

                                       <DropDownListEvents TValue="string" TItem="EditedIngredient" OnValueSelect="OnItemSelect" ValueChange="@(args => OnItemChange(args, editedIngredient))"></DropDownListEvents>

                                       <DropDownListFieldSettings Text="Item" Value="Item"></DropDownListFieldSettings>

                                   </SfDropDownList>

                               }

                           </EditTemplate>

                       </GridColumn>


                       <GridColumn Field="Field03" HeaderText="F3" EditType="EditType.DropDownEdit" Width="14%">

                           <EditTemplate>

                               @if (context is EditedIngredient editedIngredient)

                               {

                                   <SfDropDownList @ref="DDLF3" TValue="string" TItem="EditedIngredient" Placeholder="@PlaceholderF03" DataSource="@FilteredF03"

                                                   @bind-Value="editedIngredient.Field03" Enabled="@EnableF3">


                                       <DropDownListEvents TValue="string" TItem="EditedIngredient" OnValueSelect="OnF3Select"></DropDownListEvents>

                                       <DropDownListFieldSettings Text="Field03" Value="Field03"></DropDownListFieldSettings>

                                   </SfDropDownList>

                               }

                           </EditTemplate>

                       </GridColumn>


                       <GridColumn Field="Field04" HeaderText="F4" EditType="EditType.DropDownEdit" Width="9%">

                           <EditTemplate>

                               @if (context is EditedIngredient editedIngredient)

                               {

                                   <SfDropDownList @ref="DDLF4" TValue="string" TItem="EditedIngredient" Placeholder="@PlaceholderF04" DataSource="@FilteredF04"

                                                   @bind-Value="editedIngredient.Field04" Enabled="@EnableF4">

                                       <DropDownListEvents TValue="string" TItem="EditedIngredient" OnValueSelect="OnF4Select"></DropDownListEvents>

                                       <DropDownListFieldSettings Text="Field04" Value="Field04"></DropDownListFieldSettings>

                                   </SfDropDownList>

                               }

                           </EditTemplate>

                       </GridColumn>


                       <GridColumn Field="Field05" HeaderText="F5" EditType="EditType.DropDownEdit" Width="11%">

                           <EditTemplate>

                               @if (context is EditedIngredient editedIngredient)

                               {

                                   <SfDropDownList @ref="DDLF5" TValue="string" TItem="EditedIngredient" Placeholder="@PlaceholderF05" DataSource="@FilteredF05"

                                                   @bind-Value="editedIngredient.Field05" Enabled="@EnableF5">

                                       <DropDownListEvents TValue="string" TItem="EditedIngredient" OnValueSelect="OnF5Select"></DropDownListEvents>

                                       <DropDownListFieldSettings Text="Field05" Value="Field05"></DropDownListFieldSettings>

                                   </SfDropDownList>

                               }

                           </EditTemplate>

                       </GridColumn>


                       <GridColumn Field="ItemDate" HeaderText="OpenDate" EditType="EditType.DropDownEdit" Width="12%">

                           <EditTemplate>

                               @if (context is EditedIngredient editedIngredient)

                               {

                                   <SfDropDownList @ref="DDLF6" TValue="DateOnly?" TItem="EditedIngredient" Placeholder="@PlaceholderF06" DataSource="@FilteredItemDates"

                                                   @bind-Value="editedIngredient.ItemDate" Enabled="@EnableF6">

                                       <DropDownListEvents TValue="DateOnly?" TItem="EditedIngredient" OnValueSelect="OnF6Select"></DropDownListEvents>

                                       <DropDownListFieldSettings Text="ItemDate" Value="ItemDate"></DropDownListFieldSettings>

                                   </SfDropDownList>

                               }

                           </EditTemplate>

                       </GridColumn>


                       <GridColumn Field="ExpiryDate" HeaderText="ExpiryDate" EditType="EditType.DropDownEdit" Width="12%">

                           <EditTemplate>

                               @if (context is EditedIngredient editedIngredient)

                               {

                                   <SfDropDownList @ref="DDLF7" TValue="DateOnly?" TItem="EditedIngredient" Placeholder="@PlaceholderF07" DataSource="@FilteredExpiryDates"

                                                   @bind-Value="editedIngredient.ExpiryDate" Enabled="@(!string.IsNullOrEmpty(editedIngredient.ItemDate.ToString()))">

                                       <DropDownListFieldSettings Text="ItemDate" Value="ItemDate"></DropDownListFieldSettings>

                                   </SfDropDownList>

                               }

                           </EditTemplate>

                       </GridColumn>



                       <GridColumn Field="Amount" HeaderText="Amount" EditType="EditType.DefaultEdit" Width="8%">

                           <EditTemplate>

                                   @if (context is EditedIngredient editedIngredient)

                                   {

                                       <SfNumericTextBox @ref="NTBF8" TValue="decimal" Placeholder="Amount" ShowSpinButton=false Format=".########" onkeydown="blockEnterKey(event)"

                                                         @bind-Value="editedIngredient.Amount" Enabled="@(!string.IsNullOrEmpty(editedIngredient.ExpiryDate.ToString()))">

                                       </SfNumericTextBox>

                                   }

                           </EditTemplate>

                       </GridColumn>



                       <GridColumn Field="Dimension" HeaderText="Dimension" EditType="EditType.DefaultEdit" Width="6%">

                           <EditTemplate>

                               @if (context is EditedIngredient editedIngredient)

                               {

                                   <SfDropDownList @ref="DDLF9" TValue="string" TItem="string" Placeholder="Unit" DataSource="@Units"

                                                   @bind-Value="editedIngredient.Dimension" Enabled="@(editedIngredient.Amount > 0)">

                                       <DropDownListFieldSettings Text="Dimension" Value="Dimension"></DropDownListFieldSettings>

                                   </SfDropDownList>

                               }

                           </EditTemplate>

                       </GridColumn>


                   </GridColumns>

               </SfGrid>


           </Template>

       </FormItem>


When I add or edit a row in the grid, everything works fine, except if I click accidentally into the free space below the last line, the actual record will be saved. How can I prevent this, so that the record can only stored by pressing the update button?


Thanks, Hucky



3 Replies

NP Naveen Palanivel Syncfusion Team December 31, 2025 11:15 AM UTC

Hi Hartmut,

We reviewed your query and it seems that you want to update the records only by clicking the Update button in the toolbar. As per the requirement, records can be updated only by using the Update button in the toolbar. Please refer to the code snippet and sample provided below for more information.



Sample https://blazorplayground.syncfusion.com/rZVyiBKMAcGNEcMU

    <GridEditSettings AllowAdding="true" AllowEditing="true" Mode="Syncfusion.Blazor.Grids.EditMode.Normal" AllowDeleting="true" NewRowPosition="Syncfusion.Blazor.Grids.NewRowPosition.Bottom" />

 

    <GridEvents TValue="EditedIngredient" OnToolbarClick="ToolbarClickHandler" RowUpdating="RowUpdatingHandler"></GridEvents>

 

    <GridColumns>

        <GridColumn Index="1" Field=@nameof(EditedIngredient.Id) HeaderText="ID" IsPrimaryKey="true" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="60"

                    Visible="false">

 

        </GridColumn>

        <GridColumn Field="ChemOrSolText" HeaderText="Toggle" EditType="EditType.DropDownEdit"

                }

 

            </EditTemplate>

        </GridColumn>

    </GridColumns>

 

</SfGrid>

 

@code {

 

 

    private SfGrid<EditedIngredient> _ingrGrid;

 

 

    public void RowUpdatingHandler(RowUpdatingEventArgs<EditedIngredient> args)

    {

        if (allowupdate)

        {

            allowupdate = false;

        }

        else

        {

            args.Cancel = true;

        }

 

    }

 

    bool allowupdate = false;

 

    public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)

    {

        if (args.Item.Text == "Update")

        {

            allowupdate = true;

        }

       

    }

 


We also noticed that you are using the OnActionBegin event. Please note that this event will soon be deprecated for certain actions. Instead, we have introduced separate events specifically for CRUD operations. These new events allow you to handle each action more precisely.

References:




New Event Information

Event Name

Argument Name

Properties

Description

RowCreating

RowCreatingEventArgs

Cancel, Data, Index, EditContext

Gets or sets the event callback that is raised before the add action is performed in the grid.

RowCreated

RowCreatedEventArgs

Data, Index, EditContext

Gets or sets the event callback that is raised after the add action is performed in the grid.

RowUpdating

RowUpdatingEventArgs

Cancel, IsShiftKeyPressed, KeyCode, Data, Index, PreviousData, PrimaryKeys, PrimaryKeyValue

Gets or sets the event callback that is raised before the save action is performed in the grid.

RowUpdated

RowUpdatedEventArgs

Data, Index, PreviousData, PrimaryKeys, PrimaryKeyValue

Gets or sets the event callback that is raised after the save action is performed in the grid.

RowDeleting

RowDeletingEventArgs

Cancel, Datas, PrimaryKeys

Gets or sets the event callback that is raised before the delete action is performed in the grid.

RowDeleted

RowDeletedEventArgs

Datas, PrimaryKeys

Gets or sets the event callback that is raised after the delete action is performed in the grid.

EditCanceling

EditCancelingEventArgs

Cancel, Data, PreviousData, PrimaryKeys, Index

Gets or sets the event callback that is invoked before the cancel action is performed in the grid, specifically when using normal and dialog edit modes.

EditCanceled

EditCanceledEventArgs

Data, PreviousData, PrimaryKeys, Index

Gets or sets the event callback that is invoked after the cancel action is performed in the grid, specifically when using normal and dialog edit modes.

OnRowEditStart

OnRowEditStartEventArgs

Cancel, PreventDataClone

Gets or sets the event callback that is raised before an editing action is performed in the grid.

RowEditing

RowEditingEventArgs

Cancel, PrimaryKeys, PrimaryKeyValue, Data, Index, EditContext, ForeignKeyData

Gets or sets the event callback that is raised before the edit action is performed in the grid.

RowEdited

RowEditedEventArgs

PrimaryKeys, PrimaryKeyValue, Data, Index, EditContext, ForeignKeyData

Gets or sets the event callback that is raised after the edit action is performed in the grid.


Regards,

Naveen Palanivel



HA Hartmut January 1, 2026 12:36 PM UTC

Hi Naveen,


exactly what I wanted, thank you


Hartmut



NP Naveen Palanivel Syncfusion Team January 2, 2026 10:37 AM UTC

Hi Hartmut,


Welcome. We are glad to hear that the previous response was helpful.

Kindly get back to us if you have further queries. As always we will be assist you.


Regards,
Naveen


Loader.
Up arrow icon