With that said, there are some quirks. Undocumented features some might call them. Here is one of those features.
I use the Kendo UI Grid A LOT. It is tremendously useful in a variety of applications. Recently, I was building an application where I was utilizing the “inline editing” feature of the grid. Kendo allows you to setup AJAX data-bindings for CRUD inside the grid. Then you can handle the actual create, read, update, delete actions in your controller. This works magnificently.
The issue I had was that I wanted to restrict the user from updating a specific column in the grid when in Edit Mode.
Say, you have a grid setup like this:
In this example, inline editing is a cinch to setup. Simply, make the grid editable and then setup the actions the grid should call on your controller for each of the CRUD operations.
Making the grid editable only occurs at the grid level. Telerik does not provide a mechanism for enabling/disabling a specific column. Although, as with most everything in programming, there is a way.
To make this work we are going to hook into the event architecture that the Kendo Grid provides. You can check out the documentation for all of the events here:
In this code we are checking to see if the Grid is creating a new record or if we are editing an existing record. If not new, then we want to disable the first column by using jQuery to find our element and then adding the html “readonly” attribute.
This is great for times when you are using a naturally occurring key and don’t want to allow the user to change it in edit mode.
Source code formatting by: http://hilite.me/
Check out Clarity Issue Tracking - Unlimited Users, Unlimited Projects. Get Clarity with in your projects!