View Full Version : Loading JSON-data

25 Mar 2011, 12:05 AM
Hello everyone,

I'm making an application where a user has to log in. After that I want to show some data from te user.

In the LoginPanel, I'm making a AJAX-request, to check if the username and password are correct. After that, I'm fetching the user-id.

That part is working, next I'm fetching some oter data from the user, to display in an other panel. This is also working, but in my UserPanel, it seems like it doesn't know about the loaded user-data.

Is there a way to tell a panel to wait when some data is fetched from a store? Or to reload the view when a store is updated?

With this code I'm loading the 'sights' of an user. When it's loaded, I show the MainPanel.

url: Stick.configs.userTravelSights + user.id,
timeout: 12000,
method: 'GET',
disableCaching: false,
success: function(xhr) {
sights = xhr.responseText;

// sight store
Stick.stores.sightstore = new Ext.data.JsonStore({
model : 'Sight',
sorters: 'id',
data: Ext.util.JSON.decode(sights)

Stick.storesLoaded = true;


controller: 'MainController',
action: 'map',
displayObject: new Stick.views.MainPanel,
animation: {
type: 'slide',
direction: 'up',
duration: 100

In the MainPanel, I'm loading other pages.

Stick.views.MainPanel = Ext.extend(Ext.TabPanel, {
ui: 'toolbar',
tabBar: new Ext.TabBar({
dock: 'bottom',
height: 93
title: 'Kaart',
items: [
new Stick.views.Map()
title: 'Route',
items: [
new Stick.views.RoutePanel()

In the RoutePanel, I want to show the 'sights' from the user, that is stored inside the SightStore. But this doesn't seem to work (it doesn't find any data in the SightsStore).

Stick.views.RoutePanel = Ext.extend(Ext.Panel, {
initComponent: function ()
if (Stick.storesLoaded)
var arrItems = [];

// loop trough sights
Stick.stores.sightstore.each(function (e){
var panel = new Ext.Panel({
tpl: '{id}'



this.items = arrItems;
Stick.views.RoutePanel.superclass.initComponent.apply(this, arguments);

Ext.reg('stick-routepanel', Stick.views.RoutePanel);

I really hope someone can help me! Thanks in advance!