コード例 #1
0
ファイル: SiteController.php プロジェクト: Aeryris/grid
 /**
  * This example allow you to create an horizontal row, for every distinct value from a field
  *
  */
 public function hrowAction()
 {
     $grid = $this->grid();
     $grid->setSource(new Bvb_Grid_Source_Zend_Select($this->_db->select()->from('Country', array('Name', 'Continent', 'Population', 'LifeExpectancy', 'GovernmentForm', 'HeadOfState'))->limit(1000)->order('Continent ASC')));
     $grid->setNoFilters(1);
     $grid->setNoOrder(1);
     $grid->setRecordsPerPage(1200);
     $grid->updateColumn('Name', array('title' => 'Country'));
     $grid->updateColumn('Continent', array('title' => 'Continent', 'hRow' => 1));
     $grid->updateColumn('Population', array('title' => 'Population', 'class' => 'width_80'));
     $grid->updateColumn('LifeExpectancy', array('title' => 'Life E.', 'class' => 'width_50', 'decorator' => '<b>{{LifeExpectancy}}</b>'));
     $grid->updateColumn('GovernmentForm', array('title' => 'Government Form'));
     $grid->updateColumn('HeadOfState', array('title' => 'Head Of State'));
     $grid->setSqlExp(array('Population' => array('functions' => array('SUM'))));
     $extra = new Bvb_Grid_Extra_Column();
     $extra->position('right')->name('Right')->decorator("<input class='input_p'type='text' value=\"{{Population}}\" size=\"3\" name='number[]'>");
     $esquerda = new Bvb_Grid_Extra_Column();
     $esquerda->position('left')->name('Left')->decorator("<input  type='checkbox' name='number[]'>");
     $grid->addExtraColumns($extra, $esquerda);
     $this->view->pages = $grid->deploy();
     $this->render('index');
 }
コード例 #2
0
ファイル: Table.php プロジェクト: ocpyosep78/Booking
 /**
  * Builds Mass Actions
  *
  * @return string
  */
 protected function _buildMassActions()
 {
     if (!$this->getMassActions()->hasMassActions()) {
         return false;
     }
     $pk = $this->_getMassActionsDecorator();
     $left = new Bvb_Grid_Extra_Column();
     $decorator = "<input type='checkbox' onclick='observeCheckBox_" . $this->getGridId() . "(this)' " . "id='massCheckBox_" . $this->getGridId() . "' value='" . $pk . "' />";
     $left->position('left')->title('')->name('ZFG_MASS_ACTIONS')->decorator($decorator);
     $this->addExtraColumns($left);
     $select = array();
     foreach ($this->getMassActions()->getMassActionsOptions() as $value) {
         $select[$value['url']] = $value['caption'];
     }
     $formSubmitOptions = array_merge(array('onClick' => "return convertArrayToInput_" . $this->getGridId() . "()"), $this->getMassActions()->getSumitAttributes());
     $formSelect = $this->getView()->formSelect("gridAction_" . $this->getGridId(), null, array(), $select);
     $formSubmit = $this->getView()->formSubmit("send_" . $this->getGridId(), $this->__('Submit'), $formSubmitOptions);
     if ($this->getRecordsPerPage() < $this->getTotalRecords()) {
         $currentRecords = $this->getRecordsPerPage();
     } else {
         $currentRecords = $this->getTotalRecords();
     }
     $ids = $this->getSource()->getMassActionsIds($this->_data['table'], $this->getMassActions()->getFields(), $this->getMassActions()->getMultipleFieldsSeparator());
     $cssClasses = $this->getTemplateParams();
     if (!isset($cssClasses['cssClass'])) {
         $cssClasses['cssClass'] = '';
     }
     $cssClasses = $cssClasses['cssClass'];
     $cssClasses['massActions'] = isset($cssClasses['massActions']) ? " class='{$cssClasses['massActions']}'" : '';
     $cssClasses['massSelect'] = isset($cssClasses['massSelect']) ? " class='{$cssClasses['massSelect']}'" : '';
     $return = "<tr><td " . $cssClasses['massActions'] . " colspan=" . $this->_colspan . ">" . "<form style=\"padding:0;margin:0;\" method=\"post\" action=\"\" " . " id=\"massActions_{$this->getGridId()}\" name=\"massActions_{$this->getGridId()}\">" . $this->getView()->formHidden('massActionsAll_' . $this->getGridId(), $ids) . $this->getView()->formHidden('postMassIds' . $this->getGridId(), '') . "<span " . $cssClasses['massSelect'] . ">" . "<a href='#' onclick='checkAll_" . $this->getGridId() . "" . "(document.massActions_" . $this->getGridId() . ".gridMassActions_" . $this->getGridId() . "," . "{$this->getTotalRecords()},1);return false;'>" . $this->__('Select All') . "</a> | " . "<a href='#' onclick='checkAll_" . $this->getGridId() . "" . "(document.massActions_" . $this->getGridId() . ".gridMassActions_" . $this->getGridId() . "," . "{$currentRecords},0);return false;'>" . $this->__('Select Visible') . "</a> | " . "<a href='#' onclick='uncheckAll_" . $this->getGridId() . "" . "(document.massActions_" . $this->getGridId() . ".gridMassActions_" . $this->getGridId() . ",0); " . "return false;'>" . $this->__('Unselect All') . "</a> | <strong>" . "<span id='massSelected_" . $this->getGridId() . "'>0</span></strong> " . $this->__('items selected') . "</span> " . $this->__('Actions') . ": {$formSelect} {$formSubmit}" . "</form></td></tr>";
     return $return;
 }