PDA

View Full Version : grid paging always displays first page



kash22
24 Oct 2007, 2:06 PM
Hi everyone,

I have checked in firebug that I'm getting next page of data (records 26-50) from server but for some reason the grid always renders the first page (1-25). Any helpful hints would be highly appreciated.


Ext.onReady(function() {
var dsExists = false;
var branch_no = Ext.get('branch_no');
var location_name = Ext.get('location_name');
var program_code = Ext.get('program_code');
var status = Ext.get('status');
var sort_order = Ext.get('sort_order');

var ds;
var cm;
var grid;
var rz;
var gridFoot;
var paging;

locGrid = function() {

if (!dsExists) {
dsExists = true;

ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '/index2.cfm?fuseaction=branch.do_search_branch'
}),
baseParams : {branch_no: branch_no.getValue(),location_name: location_name.getValue(),program_code: program_code.getValue(),status: status.getValue(),sort_order: sort_order.getValue()},

reader: new Ext.data.JsonReader({
root: 'locations',
totalProperty: 'totalCount',
id: 'location_id'
}, [
{name: 'row'},
{name: 'branch_no'},
{name: 'location_name'},
{name: 'location_type'},
{name: 'status'},
{name: 'fee'},
{name: 'program_code'}
]),

// turn on remote sorting
remoteSort: true
});

cm = new Ext.grid.ColumnModel([{
header: "#",
dataIndex: 'row',
width: 30
},{
header: "Program",
dataIndex: 'program_code',
width: 100
},{
header: "Branch #",
dataIndex: 'branch_no',
width: 100
},{
header: "Name",
dataIndex: 'location_name',
width: 100
},{
header: "Type",
dataIndex: 'location_type',
width: 100
},{
header: "Status",
dataIndex: 'status',
width: 50
},{
header: "Fee Assess",
dataIndex: 'fee',
width: 70
}]);

// create the editor grid
grid = new Ext.grid.Grid('topic-grid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
enableColLock:false,
loadMask: true
});

// make the grid resizable, do before render for better performance
rz = new Ext.Resizable('topic-grid', {
wrap:true,
minHeight:100,
pinned:true,
handles: 's'
});
rz.on('resize', grid.autoSize, grid);

// render it

grid.render();

gridFoot = grid.getView().getFooterPanel(true);
//var gridHead = grid.getView().getHeaderPanel(true);

// add a paging toolbar to the grid's footer
paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 25,
displayInfo: true,
displayMsg: 'Displaying location(s) {0} - {1} of {2}',
emptyMsg: "No locations to display"
});



// trigger the data store load
ds.load({params:{start:0, limit:25}});
}
else {
ds.baseParams = {branch_no: branch_no.getValue(),location_name: location_name.getValue(),program_code: program_code.getValue(),status: status.getValue(),sort_order: sort_order.getValue()};
ds.load({params:{start:0, limit:25}});
}
};

Ext.get('search').on('click', locGrid);

});

kash22
24 Oct 2007, 4:29 PM
I'm now trapping the store's loadexception event and I've confimed that it's being trigered when I try to use the next page button. Now I can't figure out what to do next. please help someone I've been stuck on this problem for 2 days now :((



ds.on("loadexception", function(proxy, reader, resp,e) {
var text = resp.responseText;
alert(text)
});

tryanDLS
24 Oct 2007, 5:17 PM
Set BPs in proxy.loadResponse and see what's causing the exception - probably something wrong with what you're passing back.