PDA

View Full Version : Validator for Editor Grid panel



vijaykudayakumar
17 Jul 2008, 10:00 AM
Hi All,

This function validates the editor grid panel and shows any error if needed. some times this is very useful.
The function returns false if there is an error else it returns true.


function validateEditorGridPanel(gridId){
var grid = Ext.getCmp(gridId);
var rows = grid.store.data.length;
var cols = grid.colModel.config.length;

for (var row = 0; row < rows; row++){
var record = grid.store.getAt(row);
for (var col = 0; col < cols; col++){
var cellEditor = grid.colModel.getCellEditor(col, row);
if (cellEditor != undefined) {
var columnName = grid.colModel.getDataIndex(col);
var columnValue = record.data[columnName];
cellEditor.field.setValue(columnValue);
if (!cellEditor.field.isValid()) {
grid.startEditing(row, col);
return false;
}
}
}
}
return true;
},

Regards,
Vijay K Udayakumar

integra
9 Mar 2009, 7:13 PM
very useful this!!!
thanks!

mond
13 Apr 2011, 12:33 AM
Thanks dude.

Your Code helps a lot.!

mlekhs
9 Nov 2011, 10:40 AM
Thank you, the code works perfect.