Html.Kendo().Grid checkbox selection not working

1 Answer 51 Views
Grid
Anil kumar
Top achievements
Rank 1
Anil kumar asked on 15 Feb 2024, 09:09 AM | edited on 15 Feb 2024, 09:12 AM

Hello,

I have Html.Kendo().Grid with checkbox column based on field(IsEnabled) is true that particular grid cell with check box needs to allow the user selection. if field(IsEnabled) is false that particular cell should be disabled and not allow the user to select or deselect.

The issue I'm facing is, it is allow to select the check box in second click only. not allowing to select in single click on that check box

sample code which I am using:

columns.Bound(c => c.IsEnabled)
    .Title(Localizer["EnableDisableFlag", "PSFPro"].Value)
    .ClientTemplate("<input type='checkbox' class='check-state enableDisableFlagCB'" +
        $"onclick = 'handleEnableDisableFlagCheckBoxClicked(this);'" +
        $"#= {nameof(TransactionTypeMappingParameterViewModel.IsEnabled)} ? " +
        "'checked=checked' : '' # />")
        .Sortable(false);

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 19 Feb 2024, 05:03 PM

Hello Anil,

Would you update the ClientTemplate() option as per the example below and let me know if the checkbox can be checked and unchecked as expected at your end?

columns.Bound(c => c.IsEnabled)
    .Title(Localizer["EnableDisableFlag", "PSFPro"].Value)
    .ClientTemplate("<input type='checkbox' class='check-state enableDisableFlagCB'" +
        $"onclick = 'handleEnableDisableFlagCheckBoxClicked(event);'" +
        $"#= IsEnabled ? 'checked=checked' : 'disabled=disabled' #")
    .Sortable(false);

According to this example, the checkbox will be checked if the property "IsEnabled" equals "true". Otherwise, the checkbox will be disabled.

Here is a REPL sample for your reference:

https://netcorerepl.telerik.com/QIEmFjbA58YYK2Es22

 

Regards,
Mihaela
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
Tags
Grid
Asked by
Anil kumar
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or