PDA

View Full Version : GroupingGrid not showing groups



wboard
27 Dec 2010, 1:37 AM
Below is the Javascript for this GRID, the server returns this data (valid JSON):


[
{
"document_id": "14",
"document_type_id": "5",
"offer_name": "101504 offertetje 1 ",
"type": "Werkbon",
"modified_at": "2010-12-20",
"client": "Acme Inc",
"amount": "10.00",
"status": "Nog niet verstuurd",
"pdf_url": null,
"offer_id": "5"
}, and more of this data
]


I can't figure out what the issue is here, but no groups are shown when it tries to load the grid.


ext-all-debug.js:50996
Uncaught TypeError: Cannot read property 'groupRenderer' of undefined


This is de javascript for this grid:


var GridItem = Ext.data.Record.create([
{name: 'document_id', type: 'int'},
{name: 'document_type_id', type: 'int'},
{name: 'offer_name', type: 'string'},
{name: 'type', type: 'string'},
{name: 'modified_at', type: 'date', dateFormat: 'Y-m-d'},
{name: 'client', type: 'string'},
{name: 'amount', type: 'money'},
{name: 'status', type: 'string'},
{name: 'pdf_url', type: 'string'},
{name: 'offer_id', type: 'int'}
]);

var GridModel = new Ext.grid.ColumnModel([
{header: 'Doc Id', dataindex: 'document_id', hidden: true},
{header: 'Doc Type Id', dataindex: 'document_type_id', hidden: true},
{header: 'Offerte', dataindex: 'offer_name'},
{header: 'Type', dataindex: 'type'},
{header: 'Laatste Update', dataindex: 'modified_at', renderer: Ext.util.Format.dateRenderer('d/m/Y')},
{header: 'Klant', dataindex: 'client'},
{header: 'Bedrag', dataindex: 'amount'},
{header: 'Document Status', dataindex: 'status'},
{header: 'pdf_url', dataindex: 'pdf_url', hidden: true},
{header: 'offer_id', dataindex: 'offer_id', hidden: true}
]
);

GridModel.defaultSortable = true;

var HomeGridStore = new Ext.data.GroupingStore({
autoLoad: true,
id: 'GridStore',
proxy: new Ext.data.HttpProxy({ url: 'home_action.php?action=get_homegrid'}),
reader: new Ext.data.JsonReader({ id: 'document_id', fields: GridItem }),
groupField:'offer_id',
sortInfo: {field: 'client', direction: "ASC"}
});

var HomeGrid = new Ext.grid.GridPanel({
id: 'home_grid',
store: HomeGridStore,
cm: GridModel,
viewConfig: {forceFit: true},
autoScroll: true,
enableColLock: false,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
height: '500',
width: "100%",
view: new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
})
});

HomeGrid.render('extgrid');

Condor
27 Dec 2010, 2:05 AM
That usually happens when you enter an invalid groupField, but your groupField is a valid column.

Could it be that you are using a Ext.state.Manager and have an invalid groupField in your path cookie?

wboard
27 Dec 2010, 2:30 AM
Unfortunately not, we don't use Ext.stage.Manager...

Condor
27 Dec 2010, 2:43 AM
Then it's time to debug. Put a breakpoint on the error line and try to figure out why it can't locate the column of the current groupField.

wboard
27 Dec 2010, 3:18 AM
mmm... cfg=undefined

Condor
27 Dec 2010, 3:40 AM
As expected, but what are 'colIndex' and 'groupField' at that point?

wboard
27 Dec 2010, 4:06 AM
colIndex = -1
groupField = "offer_id"




this
Object { forceFit=true, groupTextTpl="{text} ({[values.rs.len...1 ? "Items" : "Item"]})", more...}


buf
undefined


cfg
undefined


colCount
10


colIndex
-1


cs
[Object { name="document_id", scope={...}, more...}, Object { name="document_type_id", scope={...}, more...}, Object { name="offer_name", scope={...}, more...}, 7 more...]


curGroup
undefined


ds
Object { hasMultiSort=true, multiSortInfo={...}, more...}


g
undefined


gid
undefined


groupField
"offer_id"


groupRenderer
undefined


groups
undefined


gstyle
"width:1536px;"


gvalue
undefined


i
undefined


len
undefined


prefix
undefined


r
undefined


rowIndex
undefined


rs
[Object { id="14", data={...}, more...}, Object { id="25", data={...}, more...}, Object { id="23", data={...}, more...}, 4 more...]


startRow
0


stripe
false


toString
function()


[object Window]
Window index.php

Condor
27 Dec 2010, 4:18 AM
The code contains:

colIndex = this.cm.findColumnIndex(groupField)
so that means that there is no column with dataIndex == groupField.

Are you somehow changing the columnmodel or are you using an columnmodel user extension that doesn't render hidden columns?

wboard
27 Dec 2010, 4:36 AM
we are not changing the columnmodel and not using any extensions on the columnmodel

wboard
27 Dec 2010, 4:46 AM
even when i set all columns visible, the issue remains

Condor
27 Dec 2010, 4:54 AM
It's 'dataIndex' and not 'dataindex'.

wboard
27 Dec 2010, 5:08 AM
hehe :-), thanks! this solved the problem