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

Click on row and NOT check a checkbox in a checkbox column

This should be simple but somehow it's not. I have a checkbox column in my grid called 'Enabled'. By default, when I click anywhere on a row, the checkbox gets checked, which is puzzling. I want that checkbox to be checked ONLY when I click it. When I click anywhere on the row including that checkbox, I want the row to be selected.


        <SfGrid DataSource="@users" AllowSorting="true" AllowTextWrap="true" AllowFiltering="true" AllowSelection="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">

            <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" AllowEditOnDblClick="true" ShowDeleteConfirmDialog="true" />

            <GridColumns>

                <GridColumn Field="@nameof(User.Id)" IsPrimaryKey="true" HeaderText="Id" Visible="false" />

                <GridColumn Field="@nameof(User.Enabled)" HeaderText="Enabled" Type="ColumnType.CheckBox" AutoFit="true" />

        <GridColumn Field="@nameof(User.FullName)" HeaderText="Full Name" AutoFit="true" />

                <GridColumn Field="@nameof(User.Login)" HeaderText="Login" AutoFit="true" />
        <GridColumn Field="@nameof(User.EmailAddress)" HeaderText="Email Address" AutoFit="true" />
  </GridColumns>
    </SfGrid>





1 Reply

NP Naveen Palanivel Syncfusion Team January 19, 2023 03:01 AM UTC

Hi Andy,



Greetings from Syncfusion support. 


We have validated your requirement and If you render the checkbox in the column template without defining the GridColumn Type as Checkbox, then will be able to select the row by clicking on the row and not by clicking on the checkbox. Please refer the code snippet and sample for your reference.


 

<GridColumns>

        <GridColumn  Width="50">

            <Template>

                <SfCheckBox TChecked="bool"></SfCheckBox>

            </Template>

        </GridColumn>

 



Please let us know if you have any concerns.


Regards,

Naveen Palanivel


Attachment: Checkbox_9156b59c.zip

Loader.
Up arrow icon