diff --git a/app_controller.php b/app_controller.php index 86da138..4405659 100644 --- a/app_controller.php +++ b/app_controller.php @@ -35,7 +35,7 @@ * @subpackage cake.app */ class AppController extends Controller { - var $helpers = array('Html', 'Form', 'Javascript', 'Format', 'Time'); + var $helpers = array('Html', 'Form', 'Javascript', 'Format', 'Time', 'JqGrid'); var $components = array('DebugKit.Toolbar'); function sideMenuLinks() { diff --git a/views/helpers/jq_grid.php b/views/helpers/jq_grid.php new file mode 100644 index 0000000..9b05dcc --- /dev/null +++ b/views/helpers/jq_grid.php @@ -0,0 +1,97 @@ +reset(); + } + + function reset() { + $this->jqGrid_options + = array('limit' => 20); + + $this->columns = array(); + $this->included = array(); + return $this; + } + + // Add to the set of columns for this grid + function columns($columns) { + if (isset($columns)) { + if (is_array($columns)) + $this->columns += $columns; + else + array_push($this->columns, $columns); + } + return $this; + } + + // Included fields will be included unless excluded. + function included($fields) { + if (isset($fields)) { + if (is_array($fields)) + $this->included = array_merge($this->included, $fields); + else + array_push($this->included, $fields); + } + return $this; + } + + function limit() { + $this->jqGrid_options['limit'] = 20; + return $this; + } + + function id_list($items) { + $this->jqGrid_options + += array('custom_ids' => + array_map(create_function('$data', + 'return $data["id"];'), + $items)); + return $this; + } + + function render($included = array(), $excluded = array()) { + pr("