PDA

View Full Version : store loaded, but empty list, please help



gserio
21 Oct 2011, 5:46 AM
Hi,
have this app (http://dl.dropbox.com/u/7968106/WedApp/index.html) that on login(info@demo.com | password ) retrieves some json from a server.
and here it's fine
I've loaded the json into a store, and this works too as you can see in the console.
The problem is in displaying a List within a view with that store.
here's the source (http://dl.dropbox.com/u/7968106/WedApp.zip) and below the code fragmets

i might need some tailored training :-)
Thanks for help!

CONTROLLER CODE

Ext.regController("login", {
index: function()
{
this.loginPanel = this.render({xtype: 'login-panel'});
this.loginPanel.query('#loginBtn')[0].on({
tap: this.send,
scope: this
});
WedApp.viewport.setActiveItem(this.loginPanel);
},
send: function()
{
Ext.Ajax.useDefaultXhrHeader=false;
Ext.Ajax.request({
url: 'https://api-dub.worldsecuresystems.com/api/v1/admin/tokens',
headers: {
'Content-Type' : 'application/json' },
method:'Post',
jsonData: WedApp.loginForm.getValues(),


success: function(response, opts)
{
var obj = Ext.decode(response.responseText);
console.dir(obj.token);
WedApp.siteStore = new Ext.data.Store({
model : 'Site',
sorters: 'name',
proxy: {
type: 'ajax',
url : 'https://api-dub.worldsecuresystems.com/api/v1/admin/sites',
headers :
{
'Content-Type' : 'application/json',
'Authorization':obj.token
},
reader:
{
type: 'json',
root: 'items'
}
}
});
WedApp.siteStore.load({
callback: function()
{
var site = WedApp.siteStore.first();
console.log("Orders for " + site.get('id') + ":");
this.siteListPanel = this.render({xtype: 'site-panel'});


WedApp.viewport.setActiveItem(this.siteListPanel,
{type: 'slide',direction: 'left'});
}
});
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
alert('server not available');
}
});
}

})

END CONTROLLER CODE


LIST CODE

WedApp.views.siteListPanel = Ext.extend(Ext.Panel, {
layout: {
type: 'vbox',
padding: '5',
align: 'center'
},


initComponent : function() {
this.dockedItems=
{
xtype: 'toolbar',
dock : 'top',
ui : 'light'
};
this.items=
{
xtype: 'list',
store:WedApp.contactStore,
width: 450,
height:650,
itemTpl: '<tpl for="."><div ><strong>{firstName}</strong></div></tpl>'
};
WedApp.views.siteListPanel.superclass.initComponent.apply(this, arguments);
}
});
Ext.reg('site-panel', WedApp.views.siteListPanel);

gserio
21 Oct 2011, 7:15 AM
GOT IT MY SELF,
thanks anyway!