PDA

View Full Version : problems with stores - this.ds is undefined



smick
7 Oct 2010, 3:58 PM
Hey Guys,

So I've been searching and couldn't find an answer to my problem. I guess the main problem is that I'm not sure what my problem is...

I'm new to ExtJS and am pretty much just getting my feet wet with it. I have a layout, into which I'm loading a panel, into which I'm loading a grid, which calls a store.

Problem is, when I set up the grid as a standalone object and call the store it works. However, when I call it from my grid object which is loaded in the panel, into the layout, it doesn't work. I get 'this.ds is undefined'. I'm sure it's something simple, but I've been fighting this problem for 2 days now and I would really appreciate some advice.

My code:

//layout



Ext.onReady(function() {

var application = new Ext.Viewport({

layout: 'border',
renderTo: Ext.getBody(),
items: [
{
margins: '0 100 0 100',
xtype: 'panel',
region: 'north',
contentEl: 'header' //grabs header content from div#header
},{
region: 'center',
id: 'application-content',
margins: '0 100 0 100',
items: [
search_page
]
}

]
});


});

//page loads to layout



var search_page = new Ext.Panel({

items: [{
region: 'north', //search tool bar
tbar: [ /*code removed to save space*/ ]
},{
region: 'center', //search results
xtype: 'grid',
id: 'search-data-grid',
border: false,
store: my_store,
columns: [
{header: 'id', dataIndex: 'id', width:30 },
{header: 'some_data', dataIndex: 'some_data', width: 200},
{header: 'more_data', dataIndex: 'more_data', width: 300}

]
}]
});

//data store



var my_store = new Ext.data.Store({
url: 'http://example.com/get_search_data.php',
reader: new Ext.data.JsonReader(
{
root: 'rows',
id: 'id'
},
[
'some_data',
'more_data'
]
)
});

my_store.load();

//json data



{
success:true,
rows:[
{
"id":1,
"some_data":1009851,
"more_data":"hello"
},{
"id":2,
"some_data":22345,
"more_data":"world"
}
]
}

Is there something obviously wrong with the script that would be preventing the data store from loading?

The json seems correctly formatted, and is definitely getting pulled from the server. it works with a simple data grid, but in this nexted style it just refuses to load.


Thanks for any help. I've been pulling my hair for 2 days.

evant
7 Oct 2010, 4:55 PM
Pretty much what it says, the data store that you're passing to the grid is undefined. Is it possible you're declaring the store in some closure that's making it not visible to the grid?