You can cancel grid data editing in batch edit mode on the client or server side.
In this example, users can modify data only in even rows (except the ID column). Each column is protected in a different way, listed below.
On the client, handle the BatchEditStartEditing event and set its e.cancel property to true
to cancel editing:
function OnBatchStartEdit(s, e) {
if (condition) e.cancel = true;
}
Another way to cancel editing is to use an editor's SetReadOnly method. The code sample below demonstrates how to disable an editor conditionally:
function OnBatchStartEdit(s, e) {
if (condition) {
editor = s.GetEditor(e.focusedColumn.fieldName);
editor.SetReadOnly(true);
}
You can implement custom server-side logic in the CustomJSProperties event handler:
settings.CustomJSProperties += (s, e) => {
var clientData = new Dictionary<int,object>();
var grid = s as MVCxGridView;
for (int i = 0; i < grid.VisibleRowCount; i++) {
var rowValues = grid.GetRowValues(i, new string[] {"ID", "ServerSideExample"}) as object[];
var key = Convert.ToInt32(rowValues[0]);
if (key % 2 != 0)
clientData.Add(key, "ServerSideExample");
}
e.Properties["cp_cellsToDisable"] = clientData;
};
(you will be redirected to DevExpress.com to submit your response)