PDA

View Full Version : Getting data from JsonStore to gererate GUI - data undefined



paweluz
22 Jun 2010, 5:53 AM
Hi!

I have big problem with using the JsonStore. My goal is to get the data from the database using proxy in the definition of JsonStory and then use it as a name of a checkbox in the checkbox group. When I am trying to get the data from jsonstory it tells me that data is undefined. Maybe when you look into my code you will find the solution.




var filterProxy = new Ext.data.HttpProxy({
url: 'REST/quickSearchFilter',
method: 'GET',
disableCache: false
});

var collectionNamesTab = [];
var dataToDisplay = [];
var filterStory = new Ext.data.JsonStore({
proxy: filterProxy,
autoLoad:true,
listeners:{
'load': function(obj,records){
Ext.each(records, function(rec){
console.info(rec.get('collection_urn'));
collectionNamesTab['collection_urn']=rec.get('collection_urn');
alert(collectionNamesTab['collection_urn']); // this works
dataToDisplay.push(collectionNamesTab);
});
}
},
root:'result',
fields: ['collection_urn']
});

var checkGroup = {
xtype: 'fieldset',
title: 'Title',
layout: 'fit',
border: false,
hideBorders:true,
collapsed: true, // initially collapse the group
collapsible: true,
items: [{
xtype: 'checkboxgroup',
columns:1,
items: generateCheckboxes()
}]
};

function generateCheckboxes(){
alert(collectionNamesTab['collection_urn']); // does not work !!!!!!!!!!!!!!!!!!!!!
return [
{boxLabel: 'some name', name: 'name'}

];
}



I know that there me some conflict what is generated first: the GUI or the JsonStory... and that may be my main problem. But the main question is: how to get the data from JsonStory in any time you want, and the most interesting for me: before creating the GUI of the application.

Please, can anyone help me...?

Regards,
Poul

tryanDLS
22 Jun 2010, 11:01 AM
Please stop reposting - thread moderation is on.

mslimmer
22 Jun 2010, 3:07 PM
try filterStory.on('load') { .... your code that wants to see the data}