Greetings,
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:
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:
This seems to be working well. But is this the right solution? What's the reliable method to determine if a column is editable?
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()) grid.raise_batchEditRowClosed(args); });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:
get_readOnly:function(){return(typeof(this._data.ReadOnly)!="undefined")?true:false;}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?