PDA

View Full Version : Grouping Grid & an "undefined" error



travisbell
17 Feb 2010, 11:27 PM
Hey guys,

Can anyone tell me what I am missing that is preventing this grid from loading? It's likely something obvious but I have been through the docs too many times and am starting to go blind. I need another set of eyes.



Ext.onReady(function(){
var proxy = new Ext.data.HttpProxy({
url: '/person/'+slug+'/_movies'
})

var reader = new Ext.data.JsonReader({}, [
{name: 'Slug', mapping: 'slug'},
{name: 'Title', mapping: 'title'},
{name: 'Year', mapping: 'year'},
{name: 'Department', mapping: 'department'}
])

var store = new Ext.data.GroupingStore({
reader: reader,
proxy: proxy,
sortInfo: {field: 'Year', direction: "DESC"},
groupField: 'Department'
});

store.load();

var grid = new Ext.grid.GridPanel({
store: store,
columns: [
{header: "Title", width: 100, sortable: true, dataIndex: 'Title'},
{id:'id', header: "Year", width: 60, sortable: true, dataIndex: 'Year'}
],
view: new Ext.grid.GroupingView({
forceFit: true,
groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
}),
unstyled: true,
trackMouseOver: false,
autoHeight: true,
width: 600,
frame: false,
border: false,
hideHeaders: true,
hideLabel: true,
renderTo: 'personMovies'
});
});


I have a:


<div id="personMovies"></div>

Sitting there to be rendered to.

Any chance you can see what I am doing wrong? Oh, btw, my AJAX call is responding fine.

http://img.skitch.com/20100218-tin2hn7h1ju1brt8aqc484ncmw.preview.jpg (http://skitch.com/travisbell/ni7qu/bruce-willis-tmdb)
Click for full size (http://skitch.com/travisbell/ni7qu/bruce-willis-tmdb)

evant
17 Feb 2010, 11:45 PM
The error message isn't very useful, since you aren't using ext-all-debug.

realjax
17 Feb 2010, 11:48 PM
Use ext-all-debug.js instead of ext-all.js

Will give you ( and us) a better indication of what's going on.


edit: :-)

travisbell
18 Feb 2010, 8:14 AM
Hey guys,

I've never ran into any "show stopping" issues so it's not a habit I have to use ext-all-debug.js. A testament to the Ext docs/community if you ask me ;)

Done, and now I have a real error:



cfg is undefined
groupRenderer = cfg.groupRenderer || cfg.renderer,


http://img.skitch.com/20100218-kutsxckrmda1p8ixc5r37591hh.preview.jpg (http://skitch.com/travisbell/ni9g4/bruce-willis-tmdb)
Click for full size (http://skitch.com/travisbell/ni9g4/bruce-willis-tmdb)

travisbell
18 Feb 2010, 9:51 PM
Anyone happen to be able to lend any advice? Unfortunately "cfg is undefined" means nothing to me!

evant
18 Feb 2010, 10:12 PM
Looks there's no department column in your grid.

travisbell
18 Feb 2010, 10:14 PM
Hey mate,

Yup, that did it. Does it matter with that particular column because that's what I have set as the "groupField"?

evant
18 Feb 2010, 10:15 PM
In this case, yeah. If you want to group by it, it assumes the column is visible.

It doesn't necessarily have to be that way... *makes note*.

travisbell
18 Feb 2010, 10:17 PM
Cool, now I know :D

Thanks for the help.