/admincrud/extensions/bootstrap/widgets/TbJsonButtonColumn.php
PHP | 71 lines | 38 code | 5 blank | 28 comment | 2 complexity | ed1ed0780dfaff9a0183393e16a89df6 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause
- <?php
- /**
- * TbJsonButtonColumn class
- * Works in conjunction with TbJsonGridView. Renders HTML or returns JSON according to the request to the Grid.
- *
- * @author: antonio ramirez <antonio@clevertech.biz>
- * @copyright Copyright © Clevertech 2012-
- * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
- * @package YiiBooster bootstrap.widgets
- */
- Yii::import('bootstrap.widgets.TbButtonColumn');
- /**
- * @property TbJsonGridView $grid
- */
- class TbJsonButtonColumn extends TbButtonColumn
- {
- /**
- * Renders|returns the header cell.
- */
- public function renderHeaderCell()
- {
- if ($this->grid->json) {
- ob_start();
- $this->renderHeaderCellContent();
- $content = ob_get_contents();
- ob_end_clean();
- return array('id' => $this->id, 'content' => $content);
- }
- parent::renderHeaderCell();
- }
- /**
- * Renders|returns the data cell
- *
- * @param int $row
- *
- * @return array|void
- */
- public function renderDataCell($row)
- {
- if ($this->grid->json) {
- $data = $this->grid->dataProvider->data[$row];
- $col = array();
- ob_start();
- $this->renderDataCellContent($row, $data);
- $col['content'] = ob_get_contents();
- ob_end_clean();
- $col['attrs'] = '';
- return $col;
- }
- parent::renderDataCell($row);
- }
- /**
- * Initializes the default buttons (view, update and delete).
- */
- protected function initDefaultButtons()
- {
- parent::initDefaultButtons();
- /**
- * add custom with msgbox instead
- */
- $this->buttons['delete']['click'] = strtr(
- $this->buttons['delete']['click'],
- array('yiiGridView' => 'yiiJsonGridView')
- );
- }
- }