PDA

View Full Version : grid pagination



kirankumar1231
29 Mar 2011, 2:30 AM
hello experts

i am loading 1 record per page
but when i click on the nextbutton request is not hitting the server

but when i request all the recors nextbutton works but showing up all the records

this is my extjs code


Ext.onReady(function() {
Ext.QuickTips.init();
var reader=new Ext.data.JsonReader({
root: "data",
totalProperty: "total",
fields:[
{name: 'empid',mapping:'empid'},
{name: 'empname',mapping:'empname'}
]
});
var store=new Ext.data.Store({
remoteSort:true,
proxy : new Ext.data.HttpProxy({
url: 'get.json',
method:'GET'
}),
reader:reader
});
var colModel = new Ext.grid.ColumnModel([
{header: "empid", width: 120, sortable: true, dataIndex: "empid"},
{header: "empname", width: 90, sortable: true, dataIndex: "empname"}
]);
var paging=new Ext.PagingToolbar({
pageSize:1,
store: store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
});


var grid = new Ext.grid.GridPanel({ height:200,
title:'employee details',
width:600,
store:store,
cm: colModel,
bbar:paging,
remoteSort:true,
listeners:{
keyup:function(e1){
alert("clicked me");
var a=e1.getType();
alert(a);
}
}
});
store.load({params:{start:0,limit:1}});
grid.render(document.body);
});

my sql query looks like this


String sql="select * from employee limit'"+limit+"' offset'"+limit+"'";

raduloff
29 Mar 2011, 3:36 AM
You must add total property to your load request and return it back with every next page:

request:
store.load({params:{total:yourtotalrecords, start:0,limit:1}});

responce:
{success:true,total: 16309,message: '"success"', data: [
{
Id:42,
....

mcadirci
29 Mar 2011, 3:42 AM
Why are you post same question with new threads?

There is a simple paging example at ext3 examples, please use that.

http://dev.sencha.com/deploy/dev/examples/grid/paging.html

kirankumar1231
29 Mar 2011, 3:59 AM
Why are you post same question with new threads?

There is a simple paging example at ext3 examples, please use that.

http://dev.sencha.com/deploy/dev/examples/grid/paging.html


dont know why the next button is not working as i am a new bie to this extjs

still its not working

raduloff
29 Mar 2011, 10:38 PM
Add this cod to your store:


baseParams: {offset:0,limit:1,total:0},
listeners:{'load': function(){
if(this.baseParams.total==0){
this.baseParams['total']=this.getTotalCount();
};
}},

Ext.PagingToolbar requires response with 'total' property value with EVERY page. The code above will sent to server 'total' value with every next page and server must return the same property:value. To have more than one page you need total>limit and data.length<total.So in you example the first page responce must be:

{"success":true,"total":3,"data":[{"empid":1231,"empname":"kiran kumar"}]}

This means that for the first response you must make one more query to return the total value:

SELECTcount(*) as total FROM your_table;

Don't hesitate to ask but please in the same thread.

Wish you success.

Francol
29 Sep 2011, 9:42 PM
Why are you post same question with new threads?

There is a simple paging example at ext3 examples, please use that.

http://dev.sencha.com/deploy/dev/examples/grid/paging.html
Lots of queries posted left neglected in there. Will search for in another server. Thanks..