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

Handle single click on cell

I would like to trigger an event handler when I single click on a cell in a specific row, then show a popup that uses data from other cells in that same row. That cell contains data and is not in a command column:

<GridColumn Field="@nameof(...)" HeaderText="..." AutoFit="true" />

The grid doesn't have a CellClick event. How do I accomplish this?


3 Replies

PS Prathap Senthil Syncfusion Team January 20, 2023 12:46 PM UTC

Hi Andy,

Thank you for reaching out to us.

We understand that you are looking for a way to customize the selection of cells in our Blazor DataGrid. We would like to suggest using the cell-selecting and cell-selected events in our DataGrid. These events allow you to customize the selection process and tailor it to your specific needs. Our documentation provides detailed information on how to use these events, along with examples and code snippets. You can find more information on these events here:

https://www.syncfusion.com/docs/blazor/datagrid/events#cellselecting
https://www.syncfusion.com/docs/blazor/datagrid/events#cellselected


Regards,
Prathap S



AR Andy Richard January 20, 2023 01:46 PM UTC

The CellSelecting and CellSelected events are not firing.

The links you sent me don't work. This is the proper link:

https://blazor.syncfusion.com/documentation/datagrid/events#cellselecting



<SfGrid DataSource="@roles" AllowSorting="true" AllowTextWrap="true" AllowFiltering="true" AllowSelection="false" Toolbar="@(new List<string>() { "Cancel", "Update" } )">
    <GridEditSettings AllowAdding="false" AllowEditing="true" AllowDeleting="false" AllowEditOnDblClick="true" ShowDeleteConfirmDialog="true" />
    <GridSelectionSettings Mode="Syncfusion.Blazor.Grids.SelectionMode.Cell" />
    <GridSelectionSettings CheckboxOnly="false" />
    <GridEvents QueryCellInfo="HandleRoleGridQueryCellInfo" TValue="Role" CommandClicked="HandleCommandClicked" OnBeginEdit="HandleBeginEdit" CellSelecting="HandleCellSelecting" />
    <GridColumns>
        <GridColumn Field="@nameof(Role.BaseRoleId)" IsPrimaryKey="true" HeaderText="BaseRole ID" Visible="false" />
        <GridColumn Field="@nameof(Role.ApplicationId)" HeaderText="Application ID" Visible="false" />
        <GridColumn Field="@nameof(Role.BaseRoleName)" HeaderText="App Role" AllowEditing="false" AutoFit="true" />
        <GridColumn Field="@nameof(Role.IdentityProviderGroup)" HeaderText="Identity Provider Group" AutoFit="true" />
        <GridColumn Field="@nameof(Role.CustomRoleIds)" HeaderText="Custom Role IDs" Visible="false" />
        <GridColumn Field="@nameof(Role.CustomRoleNames)" HeaderText="Custom Roles" AutoFit="true" />
        <GridColumn AutoFit="true">
            <GridCommandColumns>
                <GridCommandColumn Type="CommandButtonType.None" Title="abc" ButtonOption="@(new CommandButtonOptions(){IconCss="remove-image-icon-icon-image"})" />
            </GridCommandColumns>
        </GridColumn>
    </GridColumns>
</SfGrid>

private void HandleCellSelecting(CellSelectingEventArgs<Role> args)
{
    Console.WriteLine("");
}




PS Prathap Senthil Syncfusion Team January 23, 2023 12:26 PM UTC

Thank you for bringing this to our attention. We apologize for any confusion caused by the previous response. We understand that you are having difficulty with the normal editing type in DataGrid. To address this issue, we suggest using the Cell Selected event and setting the AllowSelection property to true. You can refer to the following documentation for more information:
https://blazor.syncfusion.com/documentation/datagrid/events#cellselected

Additionally, please note that the cell selecting event only triggers with batch editing type. We have also provided a sample solution for your reference.



Loader.
Up arrow icon