This is a migrated thread and some comments may be shown as answers.

Disable Checkbox column based on bound data

2 Answers 1816 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Iron
Mike asked on 13 Dec 2019, 07:59 PM

I have the following grid set.  Is there a way I can override the template or something else that will disable the checkbox based on a boolean from the data object?

    <kendo-grid selectable="multiple" height="600" auto-bind="false">
        <columns>
            <column selectable="true" width="30" locked="true" />
...
        </columns>
</kendo-grid>

2 Answers, 1 is accepted

Sort by
1
Accepted
Petar
Telerik team
answered on 18 Dec 2019, 09:26 AM

Hi Mike,

You cannot disable the checkboxes in the Grid directly by using the column template. Once the data in the Grid is bound, you can go through it and enable/disable the checkboxes based on the scenario in the application you are working on. Attached to my reply you will find a runnable project demonstrating how we can disable all checkboxes that are on rows with OrderID value bigger than 5. Here is the code that is executed on the dataBound event of the Grid:

    function onDataBound() {
        var grid = $("#grid").data("kendoGrid");
        var allRows = grid.items();
        $.each(allRows, function (index, value) {
            if (grid.dataItem(value).OrderID > 5) {
                 $(value).find(".k-checkbox").attr('disabled', true);
            }
        })
    }

I hope the above snippet demonstrates how you can achieve the desired functionality. Let me know if you need further assistance with the current case. 

Regards,
Petar
Progress Telerik

Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
0
Mike
Top achievements
Rank 1
Iron
answered on 19 Dec 2019, 04:24 PM
that worked, thank you.
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Iron
Answers by
Petar
Telerik team
Mike
Top achievements
Rank 1
Iron
Share this question
or