PDA

View Full Version : Ext JS 4.1.1a / grid / roweditor / validateedit / change new value



Barbe
1 Oct 2012, 11:31 AM
Hi,

I'd like to use the 'validateedit' event to apply MD5 encryption on the password field value.
I can't get it to work, what should I do ?



Ext.define('userModel', { extend: 'Ext.data.Model',
fields: [
{name:'id', type:'int', defaultValue : 0},
{name:'username', type:'string'},
{name:'password', type:'password'}
],
validations: [{
type: 'length',
field: 'password',
min: 1
}, {
type: 'length',
field: 'username',
min: 1
}]
});


var usersStore = Ext.create('Ext.data.Store', {
model: 'userModel',
data : [
{ id : 1, username : 'john', password : 'test1' },
{ id : 2, username : 'peter', password : 'test2' },
{ id : 3, username : 'max', password : 'test3' }
]
} );


var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
} );


var grid = Ext.create('Ext.grid.Panel', {
store: usersStore,
title:'Users',
renderTo: Ext.getBody(),
plugins:[ rowEditing ],
selType:'rowmodel',
columns: [
{
text : 'ID',
sortable : true,
hidden:true,
dataIndex: 'id'
},
{
text : 'User name',
sortable : true,
dataIndex: 'username',
width:200,
editor: {
xtype: 'textfield',
}
},
{
text : 'Password',
sortable : true,
dataIndex: 'password',
width:200,
editor: {
xtype: 'textfield',
inputType: 'password'
}
}
],
listeners : {
validateedit: function(editor, e, eOpts) {
e.newValues.password = e.newValues.password + '-md5';
} }
});




Thanks !

Antoine

scottmartin
1 Oct 2012, 8:37 PM
Is this to encrypt at the client, or can you simply encrypt the password at the server level? There are many md5 decrypt options online, so there will not really provide much protection if you are trying to encrypt at the client level.

Scott.

Barbe
1 Oct 2012, 10:43 PM
Thanks for the information, I'll try server-side encryption.

However, I may need to alter the new value after rowediting before the record is updated, is there a simple way to do this ?