Example #1
0
 public function setGrid(Am_Grid_Editable $grid)
 {
     parent::setGrid($grid);
     $this->decorator = new Am_Grid_Field_Decorator_LiveCheckbox($this);
     if ($this->hasPermissions()) {
         $grid->getField($this->fieldName)->addDecorator($this->decorator);
         if (!self::$jsIsAlreadyAdded) {
             $grid->addCallback(Am_Grid_ReadOnly::CB_RENDER_STATIC, array($this, 'renderStatic'));
             self::$jsIsAlreadyAdded = true;
         }
     }
 }
Example #2
0
 protected function getContent($obj, Am_Grid_Editable $grid)
 {
     if (!$this->action->isAvailable($obj)) {
         return;
     }
     $id = $this->action->getIdForRecord($obj);
     $val = $obj->{$this->field->getFieldName()};
     list($url, $params) = $this->divideUrlAndParams($this->action->getUrl($obj, $id));
     $content = sprintf('<input name="%s" class="live-checkbox" data-url="%s" data-id="%d" data-params="%s" data-value="%s" data-empty_value="%s" type="checkbox" %s/>', Am_Controller::escape($grid->getId() . '_' . $this->field->getFieldName() . '-' . $grid->escape($id)), Am_Controller::escape($url), $id, Am_Controller::escape(Am_Controller::getJson($params)), Am_Controller::escape($this->action->getValue()), Am_Controller::escape($this->action->getEmptyValue()), $val == $this->action->getValue() ? 'checked ' : '');
     return $content;
 }