Here is my thread ,i posted the actual problem of paging here in this area. you can help me from this thread sencha forum sencha forum Ext Paging problem with EXt direct Grid panel
Asked
Active
Viewed 351 times
0
-
Do you have your server side code to handle the pagination? when you click next, the grid store is called with start and limit parameters, you need to use that values to return your results from the server – objectone Feb 24 '14 at 21:13
-
Yes i get the start and limit when i apply it i get only 5 values on first load. next page is disabled – Sam Arul Raj T Feb 25 '14 at 09:11
-
You also need to get the totalProperty, i.e total number of records you want to use for pagination. The results you return should have the count of total records, say 47 and that needs to be mapped to the proxy reader totalProperty. Let me know if you need an example – objectone Feb 25 '14 at 17:55
-
I have added a simple example as answer – objectone Feb 25 '14 at 17:58
-
but my proxy is little different i use type : 'direct', and i call via directFn – Sam Arul Raj T Feb 25 '14 at 18:30
-
It doesn't matter you can still define a reader and try setting the totalProperty – objectone Feb 25 '14 at 23:01
2 Answers
1
Finally i got the answer from the forum
My Store Js
var store = Ext.create('Ext.data.Store', {
model : 'Users',
remoteSort : true,
autoLoad : true,
pageSize: 5, // items per page
sorters : [{
property : 'name',
direction : 'ASC'
}],
proxy : {
type : 'direct',
directFn : 'Users.showAllUsers',
reader: {
root: 'users'
}
}
});
My PHP function
function showAllUsers($params)
{
$sort = $params->sort[0];
$field = $sort->property;
$direction = $sort->direction;
$start = $params->start;
$end = $params->limit;
($direction == 'ASC' ? 'ASC' : 'DESC');
$dbh = Dbconfig::dbconnect();
$stmt = $dbh->prepare("SELECT count(*) FROM users");
$stmt->execute();
$number_of_rows = $stmt->fetchColumn();
$sth = $dbh->prepare("SELECT * FROM users ORDER BY name $direction LIMIT $start,$end");
$sth->execute();
$dataAll = $sth->fetchAll();
$data = array(
"success" => mysql_errno() == 0,
"total" => $number_of_rows,
"users" => $dataAll
);
return $data;
}

Sam Arul Raj T
- 1,752
- 17
- 23
0
Below is the sample on how your store and sample results should be so that your pagination works as required.
Store should look like below
var myStore = Ext.create('Ext.data.Store', {
fields: [
{name: 'firstName', type: 'string'},
{name: 'lastName', type: 'string'}
],
proxy: {
type: 'ajax',
url: '/users.json',
reader: {
type: 'json',
root: 'records',
totalProperty: 'recordCount',
successProperty: 'success'
}
}
});
and the results from your server should be like
{
recordCount: 63,
records: [
{
id: 944,
firstName: "Shannon",
lastName: "Joy"
},
{
id: 1819,
firstName: "Remi"
lastName: "Lucas"
},
.......
}

objectone
- 224
- 1
- 6