This example demonstrates how to cancel editing or disable the editor conditionally for the grid when batch editing is in use. It is possible to execute your logic either on the client or server side for a complex business model.
Then, handle the grid's client-side BatchEditStartEditing event to either cancel the edit operation using the e.cancel property:
[JScript]if(condition) e.cancel = true;
or disable the editor by obtaining its client instance:
[JScript]var editor = s.GetEditor(e.focusedColumn.fieldName); editor.SetEnabled(condition);
The custom server-side logic can be executed in the CustomJSProperties event handler:
[C#]settings.CustomJSProperties+=(s,e)=>{varclientData=newDictionary<int,object>();vargrid=sasMVCxGridView;for(inti= 0;i<grid.VisibleRowCount;i++){varrowValues=grid.GetRowValues(i,newstring[]{"ID","ServerSideExample"})asobject[];varkey=Convert.ToInt32(rowValues[0]);if(key% 2 != 0)clientData.Add(key,"ServerSideExample");}e.Properties["cp_cellsToDisable"]=clientData;};
See Also:
APSxGridView - Batch Editing - How to cancel editing or disable the editor conditionally