How to reliably determine if a GridColumn is editable?

2 posts, 1 answers
  1. Ashraf Sabry
    Ashraf Sabry avatar
    88 posts
    Member since:
    Jan 2011

    Posted 09 Jan 2014 Link to this post


    I was in bad need to RowClosing, RowClosed, RowOpening, and RowOpened client side events (I hope these will be added to a future release), so I tried to implement my own.

    I planned to handle the respective BatchEdit events. They're called for each cell, so I need to detect their call on first and last editable cells of a row to fire the proper event.

    Here are some of my code:

    function _findVisibleEditableColumn(col)
            return !col.get_readOnly() && col.get_visible();
    grid.add_batchEditClosed(function (sender, args)
                var lastVisibleEditableColumn = _.findLast(gridColumnsSortedByDisplayIndex, _findVisibleEditableColumn);
                if(lastVisibleEditableColumn && lastVisibleEditableColumn.get_uniqueName() == args.get_columnUniqueName())

    The event handler uses lo dash findLast function to find the last editable column. The callback _findVisibleEditableColumn uses the ReadOnly property to determine that the column is editable. This theoretically looks good. But I found that this doesn't cover a real scenario.

    I had a grid which had the last column a TemplateColumn without edit or insert templates specified. This column passed the check. Its ReadOnly property returns false but the BatchEditClosed event is not called for it.

    I examined the Telerik.Web.UI.GridColumn objects in the inspector and found that they have a private _data object which has the property Editable.
    get_readOnly property code is as follows:


    It doesn't use the _data.Editable property.

    At last I modified my filter function as follows:

    function _findVisibleEditableColumn(col)
            return !col.get_readOnly() && col.get_visible() && col._data.Editable;

    This seems to be working well. But is this the right solution? What's the reliable method to determine if a column is editable?
  2. Answer
    Angel Petrov
    Angel Petrov avatar
    1044 posts

    Posted 14 Jan 2014 Link to this post

    Hi Ashraf,

    I want to start with providing more clarity over the ReadOnly property. It determines whether an editor will be rendered once the item enters in edit mode. That said if it is set to true an editor will not be created for the certain column.

    Whether the column data is actually editable is determine by the IsEditable property of the column. In case of a template column it will additionally check whether an EditItemTemplate or InsertItemTemplate are declared. In order to check its value on the client you can follow the approach you have illustrated.

    Angel Petrov
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top