View Full Version : Grid with metadata: how to use totalProperty from server?

30 Jun 2010, 1:22 AM
Hi guys,

I'm using this example posted by Condor on implementing a grid with metadata from the server: http://www.sencha.com/forum/showthread.php?76406-jsonStore-gt-panel.items&p=371353#post371353

This all works well, except that I can't figure out how to use the totalProperty from the server. I'm returning the following json from the sever to populate my grid:

"metaData": {
"fields" ["3","4","5"],
"root": [{
// data here ...

In combination with the following (straightforward) javascript code:

// store
var results_store = new Ext.data.JsonStore({
url: my_url,
root: 'row',
remoteSort: true,
autoLoad: true

// grid
height: 400,
xtype: 'grid',
store: results_store,
columns: [],
stripeRows: true,
viewConfig: {
forceFit: true,
onDataChange: function(){
bbar: new Ext.PagingToolbar({
hideMode: 'offsets',
forceLayout: true,
anchor: '100%',
pageSize: 10,
store: results_store,
displayInfo: true,
displayMsg: Lng.display_count,
emptyMsg: Lng.no_rows

Now the problem is that the total value from the server equals 50, but the grid only mentions results 10 of 10 .. also the pagination doesn't work.

So my question basically is: what is the proper way to pass the totalProperty to my grid?

Thanks in advance!


30 Jun 2010, 1:35 AM
Should totalProperty not be part of your metaData?

"metaData": {
"fields" ["3","4","5"],

30 Jun 2010, 1:43 AM
Hi Fay, you are absolutely right! Thanks!

Shame on me for missing such an obvious part .. :S

Although I do recall that totalProperty has "total" as a default value already, isn't it? That gave me the idea that it shouldn't have to be explicitly defined. Anyway .. it's working!