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

Disable Cell In Grid via Javascript

2 Answers 979 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 30 May 2013, 12:54 AM
When I set the cell disable property to true the disabled attribute on the TD HTML element does not get created.
var grid = $("#" + GRID).data("kendoGrid");
var gridRow = grid.current().closest("tr");
gridRow.cells[0].disabled = true;

If you look via the debugger the cells disabled property is set to true after the above code is executed however the TD table element for the cell does NOT contain the disabled class/attribute, hence it is not rendered as disabled.

How do you disable a cell in the grid using javascript after the grid has been initially rendered?

2 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 31 May 2013, 10:53 AM
Hi Robert,


If you are referring to disabling the cell input, when editing, you could bind to the edit event of the Grid and use the e.container parameter to access the current cell/row (depending on the current edit mode).
E.g.
function(e){
    $(e.container).find("input[name='ProductName']").prop('disabled', true);
}

Please let me know if this was the information that you were looking for.

 

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jacques
Top achievements
Rank 1
answered on 05 Nov 2015, 12:44 PM

For anyone rooting around for a solution... disabling in edit event works fine if mouse clicking but if tabbing a navigatable grid it blows up the tab order.  I'm sure there are a million ways around this - I've done about 20 of them.  My current favorite is to use a readonly input field as a custom editor... set the border width 0... and add the k-textbox class.  It remains tab friendly, readable, presents consistently with other cell editors, and protects your data from editing while the column remains sortable and the underlying data updatable through the model.

Hope it helps someone.

Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Jacques
Top achievements
Rank 1
Share this question
or