PDA

View Full Version : Problem loading data in form.



fabbydesign
25 May 2012, 3:09 AM
I don't understand why is not loading data in the form:

This is the form



var editItemsMenu=Ext.create('Ext.form.Panel', { //EDIT ITEMS
id: 'edit-Items-Menu',
layout: 'absolute',
xtype:'form',
defaultType: 'textfield',
url:'menus/showItems/7/3',
border: true,
store:Ext.data.JsonStore({
storeId:'store-edit-items-menu',
fields:['objid','published', 'anchor', 'title','parameters','url'],
autoLoad: true,
waitMsg:'Loading',
proxy:{
url:'menus/showItems/7/3',
type:'ajax',
reader:{
root:'data',
type:'json'
}
}
}),
items: [
radioExternalInternal,
{
name: 'objid',
xtype: 'hidden'
},
{ fieldLabel: 'Published',
fieldWidth: 60,
msgTarget: 'side',
allowBlank: false,
x: 5,
y: 35,
name: 'published',
xtype: 'combo',
allowBlank:false,
store: [['yes', 'Yes'], ['no', 'No']],
valueField: 'yes',
editable:false,
value:'yes'
},{ fieldLabel: 'Anchor',
//fieldWidth: 90,
msgTarget: 'side',
allowBlank: false,
x: 5,
y: 70,
width:350,
name: 'anchor'
},{ fieldLabel: 'Title',

msgTarget: 'side',
allowBlank: false,
x: 5,
y: 105,
width:350,
name: 'title',
},{ fieldLabel: 'Parameters',
msgTarget: 'side',
allowBlank: true,
x: 5,
y: 140,
width:350,
name: 'parameters'
},{ fieldLabel: 'Url',
msgTarget: 'side',
allowBlank: false,
x: 5,
y: 175,
width: 500,
name: 'url'
}
],
dockedItems: [{
xtype: 'toolbar',
border:true,
items: [{
text: 'Save', // ADD ITEMS
iconCls: 'icon-save',
handler: function(){
var url = Ext.getCmp('list-Items-Menu').getStore('store-list-items-menu').proxy.url
if(url){
urlArr= url.split('/');
linkType=urlArr[2];
}
if(editItemsMenu.getForm().isValid()){
editItemsMenu.getForm().submit({
method:'POST',
url: 'menus/addItem/'+linkType,
success: function(fp, o){
Ext.getCmp('bgMenuItems').layout.setActiveItem('list-Items-Menu');
Ext.MessageBox.alert('Data added', 'Data added!');

Ext.getCmp('list-Items-Menu').getStore('store-list-items-menu').load();//refresh

},
fail: function(fp, o) {
//msg('Fail', 'erronious');
}
});
}

}
},'->', {
itemId: 'itemList',
text: 'Items list',
iconCls: 'icon-list',
handler: function(){

Ext.getCmp('bgMenuItems').layout.setActiveItem('list-Items-Menu');

}
}]
}]



});


And to load that, i use this code:



Ext.getCmp('bgMenuItems').layout.setActiveItem('edit-Items-Menu');//load subpages list
Ext.getCmp('edit-Items-Menu').getForm().load({url:'menus/showItems/7/3'});

I recieve this data from the link: menus/showItems/7/3



{success:true,data:[ { objid: "3", anchor: null, title: "Doctors in Mallorca", url: "doctors", published: "yes", parameters: ""}]}

There is no error, but the data is not loading in the form, and i don;t understand why...
Thanks...wait your response

redraid
25 May 2012, 5:11 AM
Form dont have "store" property , use loadRecord method (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.Panel-method-loadRecord ) to load model to form.


MyModelName.load(id, {
success: function (record) {
form.loadRecord(record);
}
});