核心思想是:
1.在設定grid的列的editor的時候,直接調用享用的編輯器的validateValue方法;
2.根據validateValue的結果設定列的樣式.
1的示列代碼如下:
var text={allowBlank: false};
if (minfield)
text.minValue = minfield;
if (maxfield)
text.maxValue = maxfield;
text.validateValue=function(v) {
record._valid[columnIndex]=Ext.form.NumberField.prototype.validateValue.call(this,v);
return v;
};
this.colModel
.setEditor(
2,
new Ext.grid.GridEditor(new Ext.form.NumberField(text)));
2.列的渲染的方法
renderCol: function(value, metadata, record, rowIndex, colIndex, store) {
try{
if (record._valid && (record._valid[colIndex] === false)) {
metadata.css = 'x-grid3-invalid-cell';
}
}catch(err){
}
return value;
}