PDA

View Full Version : Form reopening problem



Manunp
4 Aug 2011, 12:07 AM
Please help me i'm beginner of using EXTJS. I have managed to create form, but when i reopen the form it doesn't populate data and doesn't close too. Also combo box doesn't get selected from the json.
I'm using Grid with toolbar.

Js Code:
function doEdit(){
var userFormEdit = new Ext.FormPanel({
reader: new Ext.data.JsonReader({
fields: [
{name: 'name'},{name: 'passwd'},{name: 'fname'},{name: 'lname'},{name: 'desig'},{name: 'issuper'}
]
}),
autoHeight : true,
id : 'usrFormedit',
defaultType : 'textfield',
frame : true,
title : 'Update User',
modal : true,
monitorValid: true,
waitTitle:'Connecting',
waitMsg:'Sending data...',
url: 'backend/user_grid.php',
bodyStyle: 'padding:15px;background:transparent',
items : [
{fieldLabel : 'User Name', name: 'name', allowBlank: false, blankText:'Enter username', width:150},
{fieldLabel : 'Password', name: 'passwd', inputType: 'password', minLength: 6, allowBlank: false, blankText:'Enter Password', width:150},
{fieldLabel : 'First Name', name: 'fname', allowBlank: false, width:150},
{fieldLabel : 'Last Name', name: 'lname', allowBlank: false, width:150},
{fieldLabel : 'Designation', name: 'desig', allowBlank: false, width:150},
{xtype:'combo',hiddenName: 'super_hidden',valueField:'issuper', triggerAction:'all', mode:'local', editable:false, store:[[0, 'No'],[1, 'Yes']], fieldLabel : 'Is Super Admin', name: 'issuper',width:150},
],
buttons: [{
text: 'Update',
handler: function() {
Ext.getCmp('usrFormedit').getForm().submit({
params: {
act: "ued",
uId: EditId,
},
success:function(){
userFormEdit.getForm().reset();
myWin.hide();
var grid = Ext.getCmp('Grid');
if (grid) grid.getStore().load();
},
failure:function(form, action){
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Update Failed!');
}else{
Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ');
}
}
});
}
},{
text: 'Cancel',
handler: function() {
userFormEdit.getForm().reset();
myWin.hide();
}
}]
});

userFormEdit.getForm().load({
url: 'backend/user_grid.php',
params: {
act: 'ued',
uId: EditId,
selId: 'Transfer',
}
});

var myWin = new Ext.Window({
layout: 'form',
width: 340,
autoHeight: true,
closeAction: 'hide',
id : 'myWin',
items : [userFormEdit]
});
myWin.show();
}

Help me please, I'm stuck on that problem

mitchellsimoens
4 Aug 2011, 10:14 AM
I would help if I could read it. You need to surround you code with the BBCode code tags with code indention. Help us help you.

Manunp
4 Aug 2011, 9:15 PM
Please help me i'm beginner of using EXTJS. I have managed to create form, but when i reopen the form it doesn't populate data and doesn't close too. Also combo box doesn't get selected from the json.
I'm using Grid with toolbar.



function doEdit(){
var userFormEdit = new Ext.FormPanel({
reader: new Ext.data.JsonReader({
fields: [
{name: 'name'},{name: 'passwd'},{name: 'fname'},{name: 'lname'},{name: 'desig'},{name: 'issuper'}
]
}),
autoHeight : true,
id : 'usrFormedit',
defaultType : 'textfield',
frame : true,
title : 'Update User',
modal : true,
monitorValid: true,
waitTitle:'Connecting',
waitMsg:'Sending data...',
url: 'backend/user_grid.php',
bodyStyle: 'padding:15px;background:transparent',
items : [
{fieldLabel : 'User Name', name: 'name', allowBlank: false, blankText:'Enter username', width:150},
{fieldLabel : 'Password', name: 'passwd', inputType: 'password', minLength: 6, allowBlank: false, blankText:'Enter Password', width:150},
{fieldLabel : 'First Name', name: 'fname', allowBlank: false, width:150},
{fieldLabel : 'Last Name', name: 'lname', allowBlank: false, width:150},
{fieldLabel : 'Designation', name: 'desig', allowBlank: false, width:150},
{xtype:'combo',hiddenName: 'super_hidden',valueField:'issuper', triggerAction:'all', mode:'local', editable:false, store:[[0, 'No'],[1, 'Yes']], fieldLabel : 'Is Super Admin', name: 'issuper',width:150},
],
buttons: [{
text: 'Update',
handler: function() {
Ext.getCmp('usrFormedit').getForm().submit({
params: {
act: "ued",
uId: EditId,
},
success:function(){
userFormEdit.getForm().reset();
myWin.hide();
var grid = Ext.getCmp('Grid');
if (grid) grid.getStore().load();
},
failure:function(form, action){
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Update Failed!');
}else{
Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ');
}
}
});
}
},{
text: 'Cancel',
handler: function() {
userFormEdit.getForm().reset();
myWin.hide();
}
}]
});


userFormEdit.getForm().load({
url: 'backend/user_grid.php',
params: {
act: 'ued',
uId: EditId,
selId: 'Transfer',
}
});


var myWin = new Ext.Window({
layout: 'form',
width: 340,
autoHeight: true,
closeAction: 'hide',
id : 'myWin',
items : [userFormEdit]
});
myWin.show();
}

dmackerman
5 Aug 2011, 7:14 AM
Try setting closeAction: 'hide' on your Window configuration.

Manunp
5 Aug 2011, 10:05 PM
Mr dmackerman (http://www.sencha.com/forum/member.php?243209-dmackerman)

Thanks for the reply. But did you see my code? I have already have the code that you have mentioned in Ext.window.

Please help me