Reduced the amount of data sent to the client.
git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@827 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -586,8 +586,8 @@ class AppController extends Controller {
|
||||
// Grouping (which would not be typical)
|
||||
$query['group'] = $this->gridDataCountGroup($params, $model);
|
||||
|
||||
// DEBUG PURPOSES ONLY!
|
||||
$params['count_query'] = $query;
|
||||
if ($params['debug'])
|
||||
$params['count_query'] = $query;
|
||||
|
||||
// Get the number of records prior to pagination
|
||||
return $this->gridDataCountExecute($params, $model, $query);
|
||||
@@ -843,8 +843,8 @@ class AppController extends Controller {
|
||||
isset($params['sidx']) ? $params['sidx'] : null,
|
||||
isset($params['sord']) ? $params['sord'] : null);
|
||||
|
||||
// DEBUG PURPOSES ONLY!
|
||||
$params['query'] = $query;
|
||||
if ($params['debug'])
|
||||
$params['query'] = $query;
|
||||
|
||||
return $this->gridDataRecordsExecute($params, $model, $query);
|
||||
}
|
||||
@@ -967,6 +967,7 @@ class AppController extends Controller {
|
||||
$this->gridDataPostProcessLinks($params, $model, $records, array());
|
||||
|
||||
// DEBUG PURPOSES ONLY!
|
||||
//if ($params['debug'])
|
||||
//$params['records'] = $records;
|
||||
}
|
||||
|
||||
@@ -1044,6 +1045,7 @@ class AppController extends Controller {
|
||||
continue;
|
||||
|
||||
// DEBUG PURPOSES ONLY!
|
||||
//if ($params['debug'])
|
||||
//$params['linkrecord'][] = compact('table', 'field', 'id', 'controller', 'record');
|
||||
$record[$table][$field] =
|
||||
'<A HREF="' .
|
||||
|
||||
@@ -271,32 +271,34 @@ $jqGrid_setup = array_merge
|
||||
<div id="<?php echo $grid_id; ?>-pager" class="scroll" style="text-align:right"></div>
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
<?php if ($first_grid): ?>
|
||||
var currencyFormatter = function(cellval, opts, rowObject) {
|
||||
if (!cellval)
|
||||
return "";
|
||||
return fmtCurrency(cellval);
|
||||
}
|
||||
|
||||
var percentageFormatter = function(cellval, opts, rowObject) {
|
||||
var precision;
|
||||
if (typeof(opts.colModel) != 'undefined' &&
|
||||
typeof(opts.colModel.formatoptions) != 'undefined' &&
|
||||
typeof(opts.colModel.formatoptions.precision) != 'undefined')
|
||||
precision = opts.colModel.formatoptions.precision;
|
||||
else
|
||||
precision = 0;
|
||||
amount = cellval.toString().replace(/\%/g,'');
|
||||
amount = (amount*100).toFixed(precision);
|
||||
return amount+'%';
|
||||
}
|
||||
|
||||
var idFormatter = function(cellval, opts, rowObject) {
|
||||
if (!cellval)
|
||||
return cellval;
|
||||
return '#'+cellval;
|
||||
}
|
||||
<?php endif; ?>
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
currencyFormatter = function(cellval, opts, rowObject) {
|
||||
if (!cellval)
|
||||
return "";
|
||||
return fmtCurrency(cellval);
|
||||
}
|
||||
|
||||
percentageFormatter = function(cellval, opts, rowObject) {
|
||||
var precision;
|
||||
if (typeof(opts.colModel) != 'undefined' &&
|
||||
typeof(opts.colModel.formatoptions) != 'undefined' &&
|
||||
typeof(opts.colModel.formatoptions.precision) != 'undefined')
|
||||
precision = opts.colModel.formatoptions.precision;
|
||||
else
|
||||
precision = 0;
|
||||
amount = cellval.toString().replace(/\%/g,'');
|
||||
amount = (amount*100).toFixed(precision);
|
||||
return amount+'%';
|
||||
}
|
||||
|
||||
idFormatter = function(cellval, opts, rowObject) {
|
||||
if (!cellval)
|
||||
return cellval;
|
||||
return '#'+cellval;
|
||||
}
|
||||
|
||||
jQuery('#<?php echo $grid_id; ?>').jqGrid(
|
||||
<?php echo FormatHelper::phpVarToJavascript($jqGrid_setup); ?>
|
||||
).navGrid('#<?php echo $grid_id; ?>-pager',
|
||||
|
||||
@@ -268,14 +268,21 @@ class FormatHelper extends AppHelper {
|
||||
|
||||
|
||||
// Helper function to convert PHP vars to javascript
|
||||
function phpVarToJavascript($var, $name = '', $depth='', $special = false) {
|
||||
function phpVarToJavascript($var, $name = '', $depth='', $special = false, $pretty = false) {
|
||||
|
||||
// Establish a prefix to use before printing $var
|
||||
$prefix = $depth;
|
||||
if ($pretty) {
|
||||
$prefix = $depth;
|
||||
$pretty_sp = " ";
|
||||
$pretty_nl = "\n";
|
||||
}
|
||||
else {
|
||||
$prefix = $pretty_sp = $pretty_nl = '';
|
||||
}
|
||||
|
||||
// If given a name, set it up JS style
|
||||
if ($name)
|
||||
$prefix .= $name . ": ";
|
||||
$prefix .= $name . ":" . $pretty_sp;
|
||||
|
||||
if (!isset($var))
|
||||
return $prefix . 'null';
|
||||
@@ -328,22 +335,22 @@ class FormatHelper extends AppHelper {
|
||||
// PHP array indices can be a mix of integer and string based.
|
||||
// Just guess here, unless flagged as a special case.
|
||||
if (isset($var[0]) || $special)
|
||||
return ($prefix . "[\n"
|
||||
. implode(",\n",
|
||||
return ($prefix . "[" . $pretty_nl
|
||||
. implode("," . $pretty_nl,
|
||||
array_map(array('FormatHelper', 'phpVarToJavascript'),
|
||||
array_values($var),
|
||||
array(),
|
||||
array_fill(0, count($var), $depth.' ')
|
||||
))
|
||||
. "\n$depth]");
|
||||
. ($pretty ? "\n$depth" : '') . "]");
|
||||
|
||||
return ($prefix . "{\n"
|
||||
. implode(",\n",
|
||||
return ($prefix . "{" . $pretty_nl
|
||||
. implode("," . $pretty_nl,
|
||||
array_map(array('FormatHelper', 'phpVarToJavascript'),
|
||||
array_values($var), array_keys($var),
|
||||
array_fill(0, count($var), $depth.' ')
|
||||
))
|
||||
. "\n$depth}");
|
||||
. ($pretty ? "\n$depth" : '') . "}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ class GridHelper extends AppHelper {
|
||||
var $included, $invalid;
|
||||
var $columns;
|
||||
var $controller;
|
||||
static $first_grid = true;
|
||||
|
||||
function __construct() {
|
||||
$this->reset();
|
||||
@@ -218,8 +219,12 @@ class GridHelper extends AppHelper {
|
||||
if (isset($config))
|
||||
$this->jqGrid_options = array_merge($this->jqGrid_options, $config);
|
||||
|
||||
// Set flag whether or not this is the first grid
|
||||
$this->jqGrid_options['first_grid'] = self::$first_grid;
|
||||
|
||||
//pr(compact('config') + array('jqGrid_options' => $this->jqGrid_options));
|
||||
echo $view->element('jqGrid', $this->jqGrid_options);
|
||||
self::$first_grid = false;
|
||||
|
||||
// Since we only have one instance of this class
|
||||
// as a helper, we must assume it could be used
|
||||
|
||||
Reference in New Issue
Block a user