-
5 Mar 2012 7:49 AM #1
Ext.Direct and Grid with Paging Toolbar (Need Help!)
Ext.Direct and Grid with Paging Toolbar (Need Help!)
I'm learning tutorial (Mapping a Grid to a MySQL table using Direct and PHP Part 2) and trying to connect a Paging Toolbar to a Grid. But using the following QueryDatabase.php function I get all 1000 records from Database (it is a PhP code from zip provided by Sencha for that tutorial):
Click on Paging Toolbar Next Page button sends data with the following parameters to server: {"action":"QueryDatabase","method":"getResults","data":[{"page":3,"start":50,"limit":25}],"type":"rpc","tid":3}PHP Code:public function getResults(stdClass $params)
{
$_db = $this->__construct();
$_result = $_db->query('SELECT id, name, address, state FROM owners');
$results = array();
while ($row = $_result->fetch_assoc()) {
array_push($results, $row);
}
return $results;
}
But this function does not process(provide) those parameters.
I can remake PhP code and make it process the Query using "start" and "limit" post variables in SQL query. Also I can get a total table records amount ($total). But I need to send $total to Reader (through return function array $results).
How I can do that?
Is there any working solution for this function where all params included (sort, filter, total) ?
-
6 Mar 2012 9:20 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
This would be up to your implementation. It would be as easy as checking for a param in the request and adding the needed SQL bits to the query.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
6 Mar 2012 11:34 PM #3
Thanks. Where is better to do sorting: in SQL query or in grid?
-
9 Mar 2012 7:58 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
If you are doing paging then on the server
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote