PDA

View Full Version : Why Ext.grid.Panel does not show data?



kramal
26 Feb 2013, 12:48 AM
Hello people!

I have a little apps with code here:
But i fail to see what matter is.
Why my grid does not show data?

Thanks!


Ext.onReady(function(){


Ext.define('Mojo',{
singleton:true,
get:{
favorities:[
{text:'button1', url:'/testurl1/test.html', target: 'new'},
{text:'button2', url:'/testurl2/test.html', target: 'self'},
{text:'button3', url:'/testurl3/test.html', target: 'new'},
{text:'button4', url:'/testurl4/test.html', target: 'self'},
]
}
});


Ext.define('Task',{
extend:'Ext.panel.Panel',
title:'Task 1',
defaults:{
layout:'fit'
},
width:400,
initComponent:function(){
var me=this;


me.grid=Ext.create('Ext.grid.Panel',{
store:Mojo.get['favorities'],
columns:[
{text:'Button', dataIndex:'text',flex:1},
{text:'Text', dataIndex:'url',flex:1},
{text:'Action',flex:1}
],

});
me.grid.add([{text:'Hw',url:'sss'}]);
me.items=[me.grid];
me.renderTo=Ext.getBody();


me.callParent(arguments);
}
});


Ext.create('Task');


alert(Mojo.get.favorities.length)

});

EPV
26 Feb 2013, 3:09 AM
Hi! You should use model and store:
http://jsfiddle.net/EmilPennlov/VtxxA/1/

Some other comments:
- You don't need to put your grid in a panel, it's overnesting.
- You don't add data to the grid, you add to the store (like a database that the grid uses)
- Please use code blocks in post so that the code is more readable.

Good luck!