safewolf
28 Sep 2011, 12:29 AM
Hi, eveyone
I have a form now.
Ext.define('AdminLevel', {
extend : 'Ext.data.Model',
fields : ['id', 'level_name', 'priority'],
idProperty : 'id'
});
Ext.define('Admin.AdminLevelForm', {
extend : 'Ext.form.FormPanel',
alias : 'admin.adminlevelform',
initComponent : function() {
this.addEvents('cancelClicked', 'saveFinished');
Ext.apply(this, {
bodyPadding : 5,
waitMsgTarget : true,
defaultType : 'textfield',
fieldDefaults : {
labelAlign : 'right',
labelWidth : 85,
msgTarget : 'side',
anchor : '100%'
},
reader : new Ext.data.JsonReader({
model : 'AdminLevel',
root : 'row',
successProperty : 'success'
}),
errorReader : new Ext.data.JsonReader({
model : 'AdminLevel',
root : 'row',
successProperty : 'success'
}),
items : [{
xtype : 'hidden',
name : 'id'
}, {
fieldLabel : LANGUAGE_ADMINLEVEL_LEVEL_NAME,
name : 'level_name',
allowBlank : false
}, {
fieldLabel : LANGUAGE_ADMINLEVEL_LEVEL_PRIORITY,
name : 'priority',
allowBlank : false
}],
buttons : [{
text : 'Save',
scope : this,
handler : function() {
var form = this.getForm();
if (form.isValid()) {
form.submit({
scope : this,
url : BASEURL + URL_ADMINLEVEL_SAVE,
success : function(form, action) {
Ext.Msg.alert('Success',
// action.result.msg);
"Saved");
// result = true;
// message = "You Are Right!";
this.fireEvent("saveFinished",
true);
},
failure : function(form, action) {
Ext.Msg.alert('Failed',
action.result.msg);
}
});
} else {
alert("error");
}
}
}, {
text : 'Cancel',
scope : this,
handler : function() {
this.fireEvent("cancelClicked");
}
}]
});
this.callParent(arguments);
},
loadRow : function(guid) {
/*
* this.getForm().load({ url : BASEURL + URL_ADMINLEVEL_READ, waitMsg :
* 'Loading...', params : { id : guid } });
*/
this.getForm().load({
scope : this,
url : BASEURL + URL_ADMINLEVEL_READ,
method : 'post',
params : {
id : guid
},
success : function(form, action) {
},
failure : function(form, action) {
}
})
}
});
when I execute loadRow(1)
my server returned the json string:
{"success":true,"row":{"id":"1","level_name":"Super Admin","priority":"999"}}
and there's no error message.
But the form panel was still empty.
Anybody can help me please?
I have a form now.
Ext.define('AdminLevel', {
extend : 'Ext.data.Model',
fields : ['id', 'level_name', 'priority'],
idProperty : 'id'
});
Ext.define('Admin.AdminLevelForm', {
extend : 'Ext.form.FormPanel',
alias : 'admin.adminlevelform',
initComponent : function() {
this.addEvents('cancelClicked', 'saveFinished');
Ext.apply(this, {
bodyPadding : 5,
waitMsgTarget : true,
defaultType : 'textfield',
fieldDefaults : {
labelAlign : 'right',
labelWidth : 85,
msgTarget : 'side',
anchor : '100%'
},
reader : new Ext.data.JsonReader({
model : 'AdminLevel',
root : 'row',
successProperty : 'success'
}),
errorReader : new Ext.data.JsonReader({
model : 'AdminLevel',
root : 'row',
successProperty : 'success'
}),
items : [{
xtype : 'hidden',
name : 'id'
}, {
fieldLabel : LANGUAGE_ADMINLEVEL_LEVEL_NAME,
name : 'level_name',
allowBlank : false
}, {
fieldLabel : LANGUAGE_ADMINLEVEL_LEVEL_PRIORITY,
name : 'priority',
allowBlank : false
}],
buttons : [{
text : 'Save',
scope : this,
handler : function() {
var form = this.getForm();
if (form.isValid()) {
form.submit({
scope : this,
url : BASEURL + URL_ADMINLEVEL_SAVE,
success : function(form, action) {
Ext.Msg.alert('Success',
// action.result.msg);
"Saved");
// result = true;
// message = "You Are Right!";
this.fireEvent("saveFinished",
true);
},
failure : function(form, action) {
Ext.Msg.alert('Failed',
action.result.msg);
}
});
} else {
alert("error");
}
}
}, {
text : 'Cancel',
scope : this,
handler : function() {
this.fireEvent("cancelClicked");
}
}]
});
this.callParent(arguments);
},
loadRow : function(guid) {
/*
* this.getForm().load({ url : BASEURL + URL_ADMINLEVEL_READ, waitMsg :
* 'Loading...', params : { id : guid } });
*/
this.getForm().load({
scope : this,
url : BASEURL + URL_ADMINLEVEL_READ,
method : 'post',
params : {
id : guid
},
success : function(form, action) {
},
failure : function(form, action) {
}
})
}
});
when I execute loadRow(1)
my server returned the json string:
{"success":true,"row":{"id":"1","level_name":"Super Admin","priority":"999"}}
and there's no error message.
But the form panel was still empty.
Anybody can help me please?