There is a difference between disallowing invalid values and processing data to make it acceptable.
Disallow invalid values:
Use validations.
1. Set editModel.allowInvalid = false to disallow invalid values in cells while editing.
2. Set pasteModel.allowInvalid = false to disallow invalid values in cells while copy/paste.
Data processing:
For data loading from external data source, data could be processed manually by iterating through the rows.
data.forEach(function(rowData){
if(rowData[dataIndx].length > n)
rowData[dataIndx] = rowData[dataIndx].substring(0, n)
})
For all other actions, beforeValidate event can be used to process the data.
beforeValidate: function(evt, ui){
ui.updateList.forEach(function(obj){
var newRow = obj.newRow;
if(newRow[dataIndx].length > n)
newRow[dataIndx] = newRow[dataIndx].substring(0, n)
})
ui.addList.forEach(function(obj){
var newRow = obj.newRow;
if(newRow[dataIndx].length > n)
newRow[dataIndx] = newRow[dataIndx].substring(0, n)
})
}