PDA

View Full Version : Validations in EditorGridPanel having RowEditor



amitak
14 Oct 2009, 1:12 AM
Hi,

I am trying to put in validations for an EditorGridPanel which has a RowEditor.
1. For a field - 'Name', duplicate values can not be entered. I tried the to get the column values in an array and compared the selected row value with the values in the array. In case of an existing record, I am removing the value from the array and then comparing. The flag 'id' is used to determine if the selected record is new or not. Here's the code:


editor: new Ext.form.TextField({
validator: function(val){
var gridStore= SimpleListingEditorGrid.getStore();
var uniqueValues = gridStore.collect('Name');
var s = SimpleListingEditorGrid.getSelectionModel().getSelections();
var len = s.length-1;
var map_id = s[len].get('id');
if(map_id!= null){
uniqueValues.splice(uniqueValues.indexOf(val),1);
}
for(var i = 0;i<uniqueValues.length ; i++){
if(uniqueValues[i] === val){
return "Duplicate name!";
}
}
return true;
}
}),This does not seem to do the trick. I can still enter duplicate names. :-/

2. In the same grid, I have two date fields 'startdate' and 'enddate'. Tried the available vtypes as in the examples but it does not work in a grid. Tried putting the same in listeners: 'validateedit' for RowEditor, but I am unable to get the date picker where I could set the min and max values.

Any help would be appreciated :)