PDA

View Full Version : Grid with null data



mofo
26 Jun 2009, 4:37 AM
I have a Grid, sametimes your data is NULL and when is NULL look what happens:
sorted:
http://f.imagehost.org/0463/Untitled-1_10.png
grouped:
http://f.imagehost.org/0888/Untitled-2_4.png
and my code:


Ext.onReady(function(){
new Ext.grid.GridPanel({
xtype:'grid',
laodMask:true,
id:"grd",
border:true,
columns:[{
dataIndex:'Name',
header:'Name',
sortable:true
},{
dataIndex:'Desc',
header:'Desc',
sortable:true
}],
frame:true,
sm:new Ext.grid.RowSelectionModel({singleSelect:true}),
store:new Ext.data.GroupingStore({
autoLoad:true,
storeId:'grd',
reader:new Ext.data.ArrayReader({},[
{name:'Id'},
{name:'Name'},
{name:'Desc'}
]),
proxy:new Ext.data.PagingMemoryProxy([
[1,"Jhon","jjj"],
[2,"Mary","mmm"],
[3,"Luca",null],
[3,"Filipe","fff"],
[3,"Alberth","aaa"],
[3,"Rose",null],
[3,"Brown","bbb"]
]),
sortInfo:{
field:'Name',
direction:'ASC'
},
remoteSort:true
}),
view:new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl:'{text} ({[values.rs.length]} {[values.rs.length>1?"Itens":"Item"]})'
}),
width:500,
height:500
}).render('grd');
});
I no have ideia what's happening.
If someone can help me!

thx

ryanyoungsma
26 Jun 2009, 5:26 PM
Not really sure what your issue is or maybe really what you are asking. Your using a grouping view, but not setting the group column. Could be one reason.

Not sure you need to do state the xtype since you are calling
"new Ext.grid.GridPanel({"

My suggested changes: (still a fairly newguy myself so might work)



Ext.onReady(function(){
new Ext.grid.GridPanel({
laodMask:true,
id:"grd",
border:true,
columns:[{
dataIndex:'Name',
header:'Name',
sortable:true
},{
dataIndex:'Desc',
header:'Desc',
sortable:true
}],
frame:true,
sm:new Ext.grid.RowSelectionModel({singleSelect:true}),
store:new Ext.data.GroupingStore({
reader:new Ext.data.ArrayReader({
autoLoad:true,
storeId:'grd',
fields:[
{name:'Id'},
{name:'Name'},
{name:'Desc'}
]
)},
proxy:new Ext.data.PagingMemoryProxy([ //Never used this so who knows??
[1,"Jhon","jjj"],
[2,"Mary","mmm"],
[3,"Luca",null],
[3,"Filipe","fff"],
[3,"Alberth","aaa"],
[3,"Rose",null],
[3,"Brown","bbb"]
]),
sortInfo:{
field:'Name',
direction:'ASC'
},
remoteSort:false
groupField: 'Name' //Set your groupfield here
}),
view:new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl:'{text} ({[values.rs.length]} {[values.rs.length>1?"Itens":"Item"]})'
}),
width:500,
height:500
}).render('grd');
});


I would suggest looking the example provided in the docs.