PDA

View Full Version : ExtJs 4.1 - Uncaught Error - Cannot read property "items" of undefined.



bomslang
1 Sep 2012, 8:37 PM
Folks,

I am trying to bring a Json and bind it with the gridpanel in ExtJS 4.1.
I've checked that it's a valid Json returned. But it's not getting bind with gridpanel.

Also, it is showing me one error on console.
38401

Here's my code :-
app.js:-



var record = Ext.data.Record.create([
{name: 'id'},
{
name: 'name',
type: 'string'
}, {
name: 'title',
type: 'string'
}, {
name: 'content',
type: 'string'
}
]);

var reader = new Ext.data.reader.Json({
root: 'data',
totalProperty: 'total',
successProperty: 'success'
}, record);

var writer = new Ext.data.writer.Json({
encode: true,
writeAllFields: true
});

var store = new Ext.data.JsonStore({
proxy: proxy,
reader: reader,
writer: writer,
fields: ['id','content','name','title'],
autoSave: false
});




....
...
items: [
{
xtype: 'gridpanel',
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Title', dataIndex: 'title' },
{ text: 'Content', dataIndex: 'content', flex: 1 }
],
store: store
}
]


Here's my json returned :-


{
"data": [
{
"name": "Person1",
"id": 1,
"content": "Hello World",
"title": "First App"
},
{
"name": "Person2",
"id": 2,
"content": "Great ExtJS Application",
"title": "ExtJS"
},
{
"name": "Person3",
"id": 3,
"content": "Best HTML5 framework",
"title": "Sencha Touch"
}
],
"total": 3,
"success": true
}

bomslang
1 Sep 2012, 9:31 PM
I guess, this example runs according to ExtJS 3.0 documentation.

I got it working by checking appropriate syntax'es for similar components in ExtJS 4.1.

Thanks