PDA

View Full Version : PAGING GRID ONLY LOADS FIRST RECORD



Jagg
12 Feb 2010, 4:04 AM
HI. I HAVE THE FOLLOWNG PROBLEM. I LOAD DATA FROM MY SERVER INTO A PAGING GRID. I SEE IN FIREBUG THAT THE DATA ARE RETURNED AS EXPECTED BY THE SERVER (50 PER PAGE) BUT ONLY THE FIRST RECORD OF EACH PAGE IS LOADED IN THE STORE OF THE GRID. HERE IS MY CODE:

var proxy = new Ext.data.HttpProxy({url: '...'});

var store = new Ext.data.JsonStore({
proxy: proxy,
totalProperty: 'totalResults',
root:'myRoot',
fields: [
{name: 'par1',mapping: 'par1', type:'int'},
{name: 'par2',mapping: 'par2'}
]
});

var cm = new Ext.grid.ColumnModel([
{header: 'par1',sortable: true,dataIndex: 'par1'},
{header: par2,sortable: true,dataIndex: 'par2'}
]);

var paging = new Ext.PagingToolbar({
pageSize: 50,
store: store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: 'No topics to display'
});


var searchRusults = var grid = new Ext.grid.GridPanel({
id: 'myId',
title: 'myTitle',
store: store,
split: false,
cm: cm,
stripeRows: true,
loadMask: {
enabled: true,
msg: msg.loadMsg
},
viewConfig: {
forceFit: true
},
frame: true,
autoExpandColumn: 'par1',
autoScroll: true,
style: {
margin: '3px 0 0'
},
collapsible: true,
tbar: paging
});


Ext.getCmp('myId').store.load({params:{
start: 0,
limit: 50,
}});

SAMPLE RESULTS RETURNED BY THE SERVER ARE THE FOLLOWING:


{
"myRoot": [
{
"par1": 1,
"par2": "data1"
},
{
"par1":2,
"par2": "data2"
},
{
"par1": 3,
"par2": "data3"
},
{
"par1": 4,
"par2": "data4"
},
...
],
"totalResults": 825
}


MONITORING THE LOAD EVENT I SEE THAT ONLY ONE RECORD IS LOADED BUT I SEE ALL THE RECORDS UNDER THE STORE.READER.JSONDATA.myRoot


WHAT AM I DOING WRONG????? :((:((:((

THANKS IN ADVANCE.

daanlib
12 Feb 2010, 4:29 AM
I am not sure what is wrong with your code, but two things are going wrong with you forum post:



your code is not wrapped in [ CODE] tags (very hard to read this way);
CAPSLOCK IS NOT YOUR FRIEND ;).


PS: try setting an idProperty on your Store

Jagg
12 Feb 2010, 5:50 AM
It worked!!!
Thank you!!!
:D

tryanDLS
12 Feb 2010, 9:28 AM
Please stop using all CAPS

http://extjs.com/learn/Ext_Forum_Help#How_to_post_code_properly

Mike Robinson
12 Feb 2010, 10:08 AM
Since records are anchored in the store by their "id," if there is no "idProperty" all the records get mashed into one.