PDA

View Full Version : validate username in editor grid



chid007
12 Jul 2010, 1:39 AM
{
header: 'Username',
dataIndex: 'Username',
width: 150,
sortable: true,
editor: new Ext.form.TextField({
allowBlank: false,
validationEvent:true,
validator: function(value) {
.........!?!
}
})
}



I will validate username if username not available (http://dict.longdo.com/search/available) it will show can not use this username
plz.helpme!

Condor
12 Jul 2010, 2:16 AM
There is a RemoteValidator plugin in the User Extension forum, but you can't use it for EditorGridPanels.

You will have to write something yourself, based on the 'update' event of the store that does a server check and marks the record as invalid (e.g. using getRowClass to show the row in red) when the username can't be used.

chid007
12 Jul 2010, 10:22 PM
var editor = new Ext.ux.grid.RowEditor({
floating: true,
shadow: false,
monitorValid: true,
focusDelay: 250,
errorSummary: false,
saveText: 'Save',
cancelText: 'Cancel',
commitChangesText: 'You need to commit or cancel your changes',
errorText: 'Errors',
defaults: {
normalWidth: true
},
listeners: {
afteredit:
{
fn: function(roweditor, changes, record, rowIndex) {

if (record.get('OwnerGroupName') == "user") {
Ext.Msg.alert('Error', 'This OwnerGroupName is invalid');
// editor.startEditing(rowIndex, true); <------------------error
return false;
}
}
}
}
});



OwnerGroupName is invalid it return false and editor is on