Made the app controller include the action by default. Added virtual callouts for data order and limit. Changed fields to use formatting, including a custom format for currency and id. Added a function for auto conversion from PHP variables to javascript. Fixed some minor bugs in the controllers already converted to jqGrid. Moved leases onto jqGrid.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@118 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -63,11 +63,11 @@ class AppController extends Controller {
|
||||
* - called by function to create an index listing
|
||||
*/
|
||||
|
||||
function jqGridView($action, $title) {
|
||||
function jqGridView($title, $action = null) {
|
||||
$this->set('title', $title);
|
||||
// The resulting page will contain a jqGrid, which will
|
||||
// use ajax to obtain the actual data for this action
|
||||
$this->set('action', $action);
|
||||
$this->set('action', $action ? $action : $this->params['action']);
|
||||
$this->render('/elements/' . $this->params['controller']);
|
||||
}
|
||||
|
||||
@@ -103,13 +103,13 @@ class AppController extends Controller {
|
||||
$total = ($count < 0) ? 0 : ceil($count/$limit);
|
||||
$page = ($params['page'] <= 1) ? 1 : (($params['page'] > $total) ? $total : $params['page']);
|
||||
$start = $limit*$page - $limit;
|
||||
$sidx = isset($params['sidx']) ? $params['sidx'] : '';
|
||||
$sord = isset($params['sord']) ? ' ' . $params['sord'] : '';
|
||||
|
||||
// Grab the actual records taking pagination into account
|
||||
$query['group'] = $model->alias . '.id';
|
||||
$query['order'] = $sidx ? $sidx . $sord : null;
|
||||
$query['limit'] = $start . ', ' . $limit;
|
||||
$query['order'] = $this->jqGridDataOrder($params,
|
||||
isset($params['sidx']) ? $params['sidx'] : null,
|
||||
isset($params['sord']) ? $params['sord'] : null);
|
||||
$query['limit'] = $this->jqGridDataLimit($params, $start, $limit);
|
||||
$query['fields'] = $this->jqGridDataFields($params);
|
||||
$results = $this->jqGridDataRecords($params, $model, $query);
|
||||
|
||||
@@ -229,6 +229,17 @@ class AppController extends Controller {
|
||||
return null;
|
||||
}
|
||||
|
||||
function jqGridDataOrder(&$params, $index, $direction) {
|
||||
if ($direction)
|
||||
$direction = ' ' . $direction;
|
||||
|
||||
return $index ? $index . $direction : null;
|
||||
}
|
||||
|
||||
function jqGridDataLimit(&$params, $start, $limit) {
|
||||
return $start . ', ' . $limit;
|
||||
}
|
||||
|
||||
function jqGridDataRecordCount(&$params, $model, $query) {
|
||||
return $model->find('count', $query);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user