PDA

View Full Version : Loosing store



blade226
27 Mar 2012, 2:58 AM
Hello,

i have a neverending story. I'm already frustrated.

Here my Problem:

I load an external script in one script



treeStore = null;
artikelGrid = null;
store_benutzer = null;

Ext.Loader.setConfig({
enabled : true,
paths : {
Fake: 'jsd'
}
});

Ext.require('Fake.menue');

Ext.onReady(function() {

This part works! It shows me the Fake.menue, but after Ext.onReady i include another script



if (tabId == 'tabbenutzer'){

Ext.require('Fake.benutzer');
}


benutzer.js is opened, but it loose the store.

benutzer.js:

store_benutzer= Ext.create('Ext.data.Store', {

fields:['name', 'email', 'phone'],
data:{'items':[
{ 'xsozial': 'Lisa', "ba":"mona"}
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
artikelGrid = Ext.create ("Ext.grid.Panel" , {
title : "Daten",
store : store_benutzer,
autoScroll : true,
frame:true,
columns:[
{header:"XSozial",dataIndex:"xsozial"},
{header:"BA",dataIndex:"ba"},
{header:"Datum",dataIndex:"datum", xtype: 'datecolumn', format:'m.Y'}
]
});


artikelGrid is filled in benutzer.js, but the content never arrives.

Someone have an idea?

Thx a lot!

mitchellsimoens
27 Mar 2012, 10:31 AM
What do you mean looses the store?

blade226
27 Mar 2012, 9:40 PM
It means:

first:
in main Script

artikelGrid = 0

second:
opens the second script


artikelGrid = Ext.create ("Ext.grid.Panel" , {
title : "Daten",
store : store_benutzer,
autoScroll : true,
frame:true,
columns:[
{header:"XSozial",dataIndex:"xsozial"},
{header:"BA",dataIndex:"ba"},
{header:"Datum",dataIndex:"datum", xtype: 'datecolumn', format:'m.Y'}
]
});



third:
returning to main script:


artikelGrid = 0


I definied artikelGrid as a global variable. But after Ext.onReady the script doesn't overwrite the variable in an external script. The Problem is, that the out is in the main script and i don't want to write everything in the main script.

dedoz
28 Mar 2012, 2:14 AM
did you check that line is executed ? the line that creates the grid ? with a console.log or something ?
maybe your if (tabId == 'tabbenutzer') is never meet

blade226
28 Mar 2012, 2:25 AM
With firebug and console.log i followed the way.

The main script opens benutzer.js.
It opens the file, when i do a mouseclick on one item of the treepanel. This part works.

Via console.log i can see that artikelGrid includes an object in the benutzer.js

Then it returns to the main script und artikelGrid is null again. firebug return the error :b is null