Fixed a bug in which jqGrid would fetch data from the current controller, not the controller responsible for populating the data. Added the ability to fetch data based strictly off of an ID list, which is useful for lists that are embedded in other pages, where the list conditions are entirely foreign to the controller responsible for providing the data. To assist with this one jqGrid virtual function needed the model added as a parameter, so I added it to them all and modified the jqGrid functions in the existing derived controllers. Right now the elements (such as contacts.ctp, the only working one) receive a full list of data to populate themselves. I could have simply taken this and passed it directly to jqGrid, with no need for further server interaction. However, this could result in some very large lists, and although pagination will ensure the user is not overwhelmed, the connection or the browser could be. Unless we have a strong performance need, I'll keep it this way. In the meantime, I'll leave the underlying data available to each element, in case I have to switch over. When all is proven out, I can simplify all the queries such that the extra data is never requested in the first place.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@122 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-14 22:05:44 +00:00
parent 2cbd5da8ee
commit b6317d3ee9
7 changed files with 92 additions and 54 deletions

View File

@@ -50,7 +50,7 @@ class CustomersController extends AppController {
$params['action'] = 'all';
}
function jqGridDataTables(&$params) {
function jqGridDataTables(&$params, &$model) {
return array
('link' =>
array(// Models
@@ -60,13 +60,13 @@ class CustomersController extends AppController {
);
}
function jqGridDataFields(&$params) {
function jqGridDataFields(&$params, &$model) {
return array('Customer.*',
'COUNT(CurrentLease.id) AS lease_count');
}
function jqGridDataConditions(&$params) {
$conditions = parent::jqGridDataConditions($params);
function jqGridDataConditions(&$params, &$model) {
$conditions = parent::jqGridDataConditions($params, $model);
if ($params['action'] === 'current') {
$conditions[] = 'CurrentLease.id IS NOT NULL';
@@ -78,8 +78,8 @@ class CustomersController extends AppController {
return $conditions;
}
function jqGridDataOrder(&$params, $index, $direction) {
$order = parent::jqGridDataOrder($params, $index, $direction);
function jqGridDataOrder(&$params, &$model, $index, $direction) {
$order = parent::jqGridDataOrder($params, $model, $index, $direction);
if ($index === 'PrimaryContact.last_name') {
$order[] = 'PrimaryContact.first_name ' . $direction;
}
@@ -89,7 +89,7 @@ class CustomersController extends AppController {
return $order;
}
function jqGridDataRecordCount(&$params, $model, $query) {
function jqGridDataRecordCount(&$params, &$model, $query) {
// We don't have a good way to use the query to obtain
// our count. The problem is that we're relying on the
@@ -97,7 +97,7 @@ class CustomersController extends AppController {
// whether we omit the group by or leave it in.
// So, build a fresh query for counting.
$query['conditions'] = parent::jqGridDataConditions($params);
$query['conditions'] = parent::jqGridDataConditions($params, $model);
$count = $model->find('count',
array_merge(array('link' => array_diff_key($query['link'],