Standardized the grid events interface, to ease the burden on the views and ensure that the load functions could be used by the application without wiping out the debug functionality that was built into jqGrid.ctp
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@336 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -39,6 +39,9 @@ if (!isset($grid_id))
|
||||
if (!isset($search_fields))
|
||||
$search_fields = array();
|
||||
|
||||
if (!isset($grid_events))
|
||||
$grid_events = array();
|
||||
|
||||
if (!isset($grid_setup))
|
||||
$grid_setup = array();
|
||||
|
||||
@@ -165,6 +168,29 @@ if (1) { // debug
|
||||
$caption .= ' :: <span id="'.$grid_id.'-query"></span>';
|
||||
}
|
||||
|
||||
foreach (array_merge(array('loadComplete' => '', 'loadError' => ''),
|
||||
$grid_events) AS $event => $statement) {
|
||||
$params = '';
|
||||
if (is_array($statement)) {
|
||||
$params = key($statement);
|
||||
$statement = current($statement);
|
||||
}
|
||||
|
||||
if ($event == 'loadComplete') {
|
||||
$grid_events[$event] =
|
||||
array('--special' => "function($params) {url=jQuery('#{$grid_id}').getGridParam('url');url=url.replace(/\/debug.*$/,'?'); pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('<A HREF=\"'+url+'\">Grid Query</A><BR>'); $statement;}");
|
||||
}
|
||||
elseif ($event == 'loadError') {
|
||||
$grid_events[$event] =
|
||||
array('--special' => "function($params) {url=jQuery('#{$grid_id}').getGridParam('url');url=url.replace(/\/debug.*$/,'?'); pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('<A HREF=\"'+url+'\">Grid Error Query</A><BR>'); $statement;}");
|
||||
}
|
||||
else {
|
||||
$grid_events[$event] =
|
||||
array('--special' => "function($params) { $statement; }");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Configure the grid setup, giving priority to user defined parameters
|
||||
$jqGrid_setup = array_merge
|
||||
(array('mtype' => 'GET',
|
||||
@@ -182,11 +208,8 @@ $jqGrid_setup = array_merge
|
||||
'imgpath' => $imgpath,
|
||||
'viewrecords' => true,
|
||||
'pager' => $grid_id.'-pager',
|
||||
|
||||
'loadComplete' => array('--special' => "function() {url=jQuery('#{$grid_id}').getGridParam('url');url=url.replace(/\/debug.*$/,'?'); pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('<A HREF=\"'+url+'\">Grid Query</A><BR>');}"),
|
||||
'loadError' => array('--special' => "function(xhr,st,err) {url=jQuery('#{$grid_id}').getGridParam('url');url=url.replace(/\/debug.*$/,'?'); pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('<A HREF=\"'+url+'\">Grid Error Query</A><BR>');}"),
|
||||
|
||||
),
|
||||
$grid_events,
|
||||
$grid_setup
|
||||
);
|
||||
//pr(compact('grid_setup', 'jqGrid_setup'));
|
||||
|
||||
Reference in New Issue
Block a user