OnCellEdit not firing

I have my Grid control setup as so:

                                    <SfGrid DataSource="@pcb.Components" ShowColumnChooser="true"  AllowSorting="true" AllowFiltering="true" GridLines="GridLine.Both" AllowPaging="true" Height="75%" AllowResizing="true" ID="ComponentGrid" @ref="ComponentGrid">
                                        <GridSelectionSettings PersistSelection="true" />
                                        <GridEditSettings AllowEditing="true" />
                                        <GridPageSettings PageCount="2" PageSize="20" />
                                        <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel"/>
                                        <GridSelectionSettings EnableSimpleMultiRowSelection="true" Mode="Syncfusion.Blazor.Grids.SelectionMode.Row"/>

                                        <GridEvents Created="OnComponentGridCreated" RowSelected="@ComponentRowSelected" TValue="PCB_Component" OnRecordClick="OnComponentRecordClicked" OnCellEdit="On_CellEdit" />

                                        <GridColumns>
                                            <GridColumn Field=@nameof(PCB_Component.Installed) Width="10%" Type="ColumnType.Boolean" EditType="EditType.BooleanEdit"  DisplayAsCheckBox="true"  />
                                            <GridColumn Field=@nameof(PCB_Component.Name) IsPrimaryKey="true" HeaderText="Component" Width="100" AllowEditing="false" />
                                            <GridColumn Field=@nameof(PCB_Component.Description) HeaderText="Description" Width="200" AllowEditing="false" />
                                            <GridColumn Field=@nameof(PCB_Component.Package) HeaderText="Package" AllowEditing="false" />
                                        </GridColumns>

                                    </SfGrid>

My callback method is:

    public async Task On_CellEdit(CellEditArgs<PCB_Component> args)
    {
        var d = args.Data;
        AppState.PrintDebug(d.Installed.ToString());
    }

When I change the state of the checkbox in the first column of the grid the callback function is  not being called.

Please advise.


5 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team November 4, 2020 04:15 AM UTC

Hi Jim,  

Thanks for contacting Syncfusion support.  

Query: “When I change the state of the checkbox in the first column of the grid the callback function is  not being called. 

We have analyzed your query and we would like to inform you that Cell based editing events like (OnCellEdit, OncellSave, CellSaved etc) will be triggered only when EditMode is of Batch type. Refer the below UG documentation on batch edit mode for your reference 


By default (when Editmode of GridEditSettings is not defined) EditMode og GridEditSettings will be of Normal / Inline. We understand that you want an callback event to be triggered when Boolean value is changed . Can you please share more details about your requirement and action you want to perform in callback function. It will be very helpful for us to analyze the query at our end and provide solution as early as possible.      
  
Regards, 
Vignesh Natarajan 



JY Jim Young November 4, 2020 04:25 AM UTC

My need for the callback is to save the state of the row in local storage. I only want to save the state if the bool value is true. I'm trying to create a solution that has a minimal interface, without any toolbars. I have the grid set to call StartEdit() with the row is selected and only the first column with the checkbox is editable.


VN Vignesh Natarajan Syncfusion Team November 5, 2020 06:31 AM UTC

Hi Jim,  
 
Thanks for the details.  
 
Query: “My need for the callback is to save the state of the row in local storage. I only want to save the state if the bool value is true 
 
We have analyzed your query and we suggest you to achieve your requirement using EditTemplate feature of the Grid. Inside the EditTemplate of the Boolean column, we suggest you to render checkbox component with ValueChange event.  
 
Refer the below code example.  
 
<SfGrid DataSource="@Components" ShowColumnChooser="true" AllowSorting="true" AllowFiltering="true" GridLines="GridLine.Both" AllowPaging="true" Height="75%" AllowResizing="true" ID="ComponentGrid" @ref="ComponentGrid"> 
    <GridEvents Created="OnComponentGridCreated" RowSelected="@ComponentRowSelected" TValue="PCB_Component" OnRecordClick="OnComponentRecordClicked" OnCellEdit="On_CellEdit" />  
    <GridColumns> 
        <GridColumn Field=@nameof(PCB_Component.Installed) Width="10%" Type="ColumnType.Boolean" EditType="EditType.BooleanEdit" DisplayAsCheckBox="true"> 
            <EditTemplate> 
                @{ 
                    var order = (context as PCB_Component); 
                    <SfCheckBox @bind-Checked="@order.Installed" TChecked="bool?" ValueChange="@((ChangeEventArgs<bool?> args) => valueChange(args.Checked))"></SfCheckBox> 
                }  
            </EditTemplate> 
        </GridColumn> 
        <GridColumn Field=@nameof(PCB_Component.Name) IsPrimaryKey="true" HeaderText="Component" Width="100" AllowEditing="false" /> 
        <GridColumn Field=@nameof(PCB_Component.Description) HeaderText="Description" Width="200" AllowEditing="false" /> 
        <GridColumn Field=@nameof(PCB_Component.Package) HeaderText="Package" AllowEditing="false" /> 
    </GridColumns>  
</SfGrid> 
  
@code{ 
    SfGrid<PCB_Component> ComponentGrid { getset; } 
    public List<PCB_Component> Components { getset; } 
    public void valueChange(bool? val) 
    { 
  
    } 
 
 
For your convenience we have prepared a sample which can be downloaded from below  
 
 
Refer our UG documentation for your reference 
 
 
Please get back to us if you have further queries.    
 
Regards, 
Vignesh Natarajan 


Marked as answer

JY Jim Young November 6, 2020 03:14 AM UTC

Thank you. The sample code was a great help.


VN Vignesh Natarajan Syncfusion Team November 6, 2020 04:53 AM UTC

Hi Jim, 

Thanks for the update.  

We are glad to hear that you have resolved your query using our solution. 

Kindly get back to us if you have further queries.  

Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon