コード例 #1
0
 public function init()
 {
     $this->viewButtonLabel = '<i class="glyphicon glyphicon-search" title="' . Yii::t('EBootstrap', 'View') . '"></i>';
     $this->updateButtonLabel = '<i class="glyphicon glyphicon-pencil" title="' . Yii::t('EBootstrap', 'Update') . '"></i>';
     $this->deleteButtonLabel = '<i class="glyphicon glyphicon-trash" title="' . Yii::t('EBootstrap', 'Delete') . '"></i>';
     parent::init();
 }
コード例 #2
0
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     if ($this->customButtonLabel === null) {
         $this->customButtonLabel = Yii::t('zii', 'Custom');
     }
     // if($this->proyectosButtonLabel===null)
     // 	$this->proyectosButtonLabel=Yii::t('zii','proyectos');
     if ($this->viewButtonIcon !== false && !isset($this->buttons['view']['icon'])) {
         $this->buttons['view']['icon'] = $this->viewButtonIcon;
     }
     if ($this->updateButtonIcon !== false && !isset($this->buttons['update']['icon'])) {
         $this->buttons['update']['icon'] = $this->updateButtonIcon;
     }
     if ($this->deleteButtonIcon !== false && !isset($this->buttons['delete']['icon'])) {
         $this->buttons['delete']['icon'] = $this->deleteButtonIcon;
     }
     if ($this->customButtonIcon !== false && !isset($this->buttons['custom']['icon'])) {
         $this->buttons['custom']['icon'] = $this->customButtonIcon;
     }
     if ($this->materialsButtonIcon !== false && !isset($this->buttons['materials']['icon'])) {
         $this->buttons['materials']['icon'] = $this->materialsButtonIcon;
     }
     if ($this->publicacionesButtonIcon !== false && !isset($this->buttons['folder']['icon'])) {
         $this->buttons['publicaciones']['icon'] = $this->publicacionesButtonIcon;
     }
 }
コード例 #3
0
 protected function initDefaultButtons()
 {
     if ($this->modelClassName != "") {
         $modelClass = $this->modelClassName;
     } else {
         $modelClass = $this->grid->dataProvider->modelClass;
     }
     $controller = $modelClass;
     // do not lowercase the names, it breaks
     if (is_array($modelClass::model()->primaryKey)) {
         if ($this->returnTo != "") {
             $paramExpression = '",array_merge($data->primaryKey, array("returnTo" => "' . urlencode($this->returnTo) . '"))';
         } else {
             $paramExpression = '",$data->primaryKey';
         }
     } else {
         if ($this->returnTo != "") {
             $paramExpression = '",array("id"=>$data->primaryKey, "returnTo" => "' . urlencode($this->returnTo) . '")';
         } else {
             $paramExpression = '",array("id"=>$data->primaryKey)';
         }
     }
     /*
             if(isset($this->returnTo)){
                 $paramExpression .= ",'returnTo' => ". "'$this->returnTo'";
             }
     */
     $paramExpression .= ")";
     foreach (array('view', 'update', 'delete') as $id) {
         $this->{$id . 'ButtonUrl'} = 'Yii::app()->urlManager->createUrl("' . "{$controller}/{$id}{$paramExpression}";
     }
     parent::initDefaultButtons();
 }
コード例 #4
0
ファイル: MyButtonColumn.php プロジェクト: ASDAFF/its-crm
 public function init()
 {
     $this->viewButtonImageUrl = Yii::app()->request->baseUrl . '/css/img/fsi-icons/zoom.png';
     $this->updateButtonImageUrl = Yii::app()->request->baseUrl . '/css/img/btn/i-edit.png';
     $this->deleteButtonImageUrl = Yii::app()->request->baseUrl . '/css/img/btn/i-cancel.png';
     return parent::init();
 }
コード例 #5
0
ファイル: MyButtonColumn.php プロジェクト: Aplay/anetika_site
 /**
  *### .initDefaultButtons()
  *
  * Initializes the default buttons (view, update and delete).
  */
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     if ($this->viewButtonIcon !== false && !isset($this->buttons['view']['icon'])) {
         $this->buttons['view']['icon'] = $this->viewButtonIcon;
     }
     if ($this->viewInButtonIcon !== false && !isset($this->buttons['viewin']['icon'])) {
         $this->buttons['viewin']['icon'] = $this->viewInButtonIcon;
     }
     if ($this->updateButtonIcon !== false && !isset($this->buttons['update']['icon'])) {
         $this->buttons['update']['icon'] = $this->updateButtonIcon;
     }
     if ($this->deleteButtonIcon !== false && !isset($this->buttons['delete']['icon'])) {
         $this->buttons['delete']['icon'] = $this->deleteButtonIcon;
     }
     $this->buttons['view']['options']['class'] = $this->viewButtonClass;
     $this->buttons['viewin']['options']['class'] = $this->viewInButtonClass;
     $this->buttons['update']['options']['class'] = $this->updateButtonClass;
     $this->buttons['delete']['options']['class'] = $this->deleteButtonClass;
     /*if (!empty($this->buttons['view']['icon']))
     			$this->buttons['view']['icon'] .= ' white';
     		if (!empty($this->buttons['update']['icon']))
     			$this->buttons['update']['icon'] .= ' white';
     		if (!empty($this->buttons['delete']['icon']))
     			$this->buttons['delete']['icon'] .= ' white';
     		*/
 }
コード例 #6
0
    function __construct($grid)
    {
        parent::__construct($grid);
        //Уберем сортировку по колонкам, она уже не нужна
        if ($this->disableSortable) {
            foreach ($grid->columns as $key => $column) {
                if (is_object($column)) {
                    if (get_class($column) == 'CDataColumn') {
                        $column->sortable = false;
                    }
                }
            }
        }
        //CVarDumper::dump($this->grid->dataProvider->getSort()->orderBy,2,true);
        $this->template = '{moveup}{movedown}';
        $imgPath = $this->publish();
        $move = <<<EOD
\t\tfunction() {

\t\t\t\$.fn.yiiGridView.update('{$this->grid->id}', {
\t\t\t\ttype:'POST',
\t\t\t\turl:\$(this).attr('href'),
\t\t\t\tsuccess:function() {
\t\t\t\t\t\$.fn.yiiGridView.update('{$this->grid->id}');
\t\t\t\t}
\t\t\t});

\t\t\treturn false;

\t\t}
EOD;
        $this->buttons = array('moveup' => array('label' => 'Вверх', 'url' => 'array("default/move", "method"=>"up", "id" => $data->id)', 'imageUrl' => $imgPath . '/up.png', 'options' => array('class' => 'moveup'), 'click' => $move), 'movedown' => array('label' => 'Вниз', 'url' => 'array("default/move", "method"=>"down", "id" => $data->id)', 'imageUrl' => $imgPath . '/down.png', 'options' => array('class' => 'movedown'), 'click' => $move));
    }
コード例 #7
0
ファイル: IconButtonColumn.php プロジェクト: vman747/virex
 public function init()
 {
     $this->deleteButtonImageUrl = '/images/icons/cross.png';
     //$this->updateButtonImageUrl = '/images/icons/page_white_edit.png';
     //$this->viewButtonImageUrl = '/images/icons/page_white_magnify.png';
     $this->updateButtonImageUrl = '/images/icons/pencil.png';
     $this->viewButtonImageUrl = '/images/icons/magnifier.png';
     $this->htmlOptions = array('style' => 'text-align:center;');
     parent::init();
 }
コード例 #8
0
ファイル: TbButtonColumn.php プロジェクト: GsHatRed/Yiitest
    /**
     * ### .initDefaultButtons()
     *
     * Initializes the default buttons (view, update and delete).
     */
    protected function initDefaultButtons()
    {
        if ($this->deleteConfirmation === null) {
            $this->deleteConfirmation = Yii::t('zii', 'Are you sure you want to delete this item?');
        }
        if (!isset($this->buttons['delete']['click'])) {
            if (is_string($this->deleteConfirmation)) {
                $confirmation = CJavaScript::encode($this->deleteConfirmation);
            } else {
                $confirmation = '';
            }
            if (Yii::app()->request->enableCsrfValidation) {
                $csrfTokenName = Yii::app()->request->csrfTokenName;
                $csrfToken = Yii::app()->request->csrfToken;
                $csrf = "\n\t\tdata:{ '{$csrfTokenName}':'{$csrfToken}' },";
            } else {
                $csrf = '';
            }
            if ($this->afterDelete === null) {
                $this->afterDelete = 'function(){}';
            }
            $this->buttons['delete']['click'] = <<<EOD
function(e) {
        var th = this,
                 afterDelete = {$this->afterDelete};
        e.preventDefault();
        window.confirm({$confirmation}, function(ret){
            if(ret == false) return;  
            jQuery('#{$this->grid->id}').yiiGridView('update', {
                    type: 'POST',
                    url: jQuery(th).attr('href'),{$csrf}
                    success: function(data) {
                            jQuery('#{$this->grid->id}').yiiGridView('update');
                            afterDelete(th, true, data);
                    },
                    error: function(XHR) {
                            return afterDelete(th, false, XHR);
                    }
            });
        });
}
EOD;
        }
        parent::initDefaultButtons();
        if ($this->viewButtonIcon !== false && !isset($this->buttons['view']['icon'])) {
            $this->buttons['view']['icon'] = $this->viewButtonIcon;
        }
        if ($this->updateButtonIcon !== false && !isset($this->buttons['update']['icon'])) {
            $this->buttons['update']['icon'] = $this->updateButtonIcon;
        }
        if ($this->deleteButtonIcon !== false && !isset($this->buttons['delete']['icon'])) {
            $this->buttons['delete']['icon'] = $this->deleteButtonIcon;
        }
    }
コード例 #9
0
ファイル: ButtonColumn.php プロジェクト: wanyos2005/hsbf
 public function init()
 {
     if (empty($this->deleteConfirmation)) {
         $this->deleteConfirmation = Lang::t('DELETE_CONFIRM');
     }
     if (empty($this->header)) {
         $this->header = 'Actions';
     }
     $this->htmlOptions['class'] = isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' button-column' : 'button-column';
     parent::init();
 }
コード例 #10
0
ファイル: AdminButtonColumn.php プロジェクト: kostya1017/our
 public function init()
 {
     if (isset(Yii::app()->cms->currentSectionId)) {
         if ($this->updateButtonUrl == 'Yii::app()->controller->createUrl("update",array("id"=>$data->primaryKey))') {
             $this->updateButtonUrl = 'Yii::app()->controller->createUrl("update",array("id"=>$data->primaryKey,"section_id"=>Yii::app()->cms->currentSectionId))';
         }
         if ($this->deleteButtonUrl == 'Yii::app()->controller->createUrl("delete",array("id"=>$data->primaryKey))') {
             $this->deleteButtonUrl = 'Yii::app()->controller->createUrl("delete",array("id"=>$data->primaryKey,"section_id"=>Yii::app()->cms->currentSectionId))';
         }
     }
     return parent::init();
 }
コード例 #11
0
 public function init()
 {
     if ($this->viewButtonImageUrl === null) {
         $this->viewButtonImageUrl = Yii::app()->request->baseUrl . '/images/admin/view.png';
     }
     if ($this->updateButtonImageUrl === null) {
         $this->updateButtonImageUrl = Yii::app()->request->baseUrl . '/images/admin/edit.png';
     }
     if ($this->deleteButtonImageUrl === null) {
         $this->deleteButtonImageUrl = Yii::app()->request->baseUrl . '/images/admin/delete.png';
     }
     parent::init();
 }
コード例 #12
0
 /**
  * Initializes the default buttons (view, update and delete).
  */
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     if ($this->viewButtonIcon !== false && !isset($this->buttons['view']['icon'])) {
         $this->buttons['view']['icon'] = $this->viewButtonIcon;
     }
     if ($this->updateButtonIcon !== false && !isset($this->buttons['update']['icon'])) {
         $this->buttons['update']['icon'] = $this->updateButtonIcon;
     }
     if ($this->deleteButtonIcon !== false && !isset($this->buttons['delete']['icon'])) {
         $this->buttons['delete']['icon'] = $this->deleteButtonIcon;
     }
 }
コード例 #13
0
 protected function renderDataCellContent($row, $data)
 {
     $tmpTemplate = $this->template;
     $tmpButtons = $this->buttons;
     $this->template = $this->evaluateExpression($this->template, array('data' => $data, 'row' => $row));
     foreach ($this->buttons as $buttonIndex => $button) {
         foreach ($button['options'] as $optionIndex => $option) {
             $this->buttons[$buttonIndex]['options'][$optionIndex] = $this->evaluateExpression($this->buttons[$buttonIndex]['options'][$optionIndex], array('data' => $data, 'row' => $row));
         }
     }
     parent::renderDataCellContent($row, $data);
     $this->template = $tmpTemplate;
     $this->buttons = $tmpButtons;
 }
コード例 #14
0
 /**
  * @inheritdoc
  */
 protected function renderButton($id, $button, $row, $data)
 {
     if (!empty($button['icon'])) {
         if (!isset($button['options']['title'])) {
             $button['options']['title'] = isset($button['label']) ? $button['label'] : $id;
         }
         $button['label'] = Html::icon($button['icon']);
         $button['imageUrl'] = null;
     }
     if ($this->enableTooltips) {
         $button['options']['data-toggle'] = 'tooltip';
     }
     parent::renderButton($id, $button, $row, $data);
 }
コード例 #15
0
ファイル: SSortableColumn.php プロジェクト: rash012/cms
 /**
  * Initialization
  */
 public function init()
 {
     if ($this->imagePath === null) {
         $this->imagePath = $this->publish();
     }
     $movePath = '';
     if ($this->controller) {
         $movePath .= $this->controller . '/';
     }
     $this->buttons['moveup']['url'] = 'array("' . $movePath . 'move", "method" => "up", "id" => $data->id)';
     $this->buttons['moveup']['imageUrl'] = $this->imagePath . '/up.png';
     $this->buttons['movedown']['url'] = 'array("' . $movePath . 'move", "method" => "down", "id" => $data->id)';
     $this->buttons['movedown']['imageUrl'] = $this->imagePath . '/down.png';
     parent::init();
 }
コード例 #16
0
 /**
  * Initializes the default buttons (view, update and delete).
  */
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     if ($this->viewButtonIcon !== false && !isset($this->buttons['view']['icon'])) {
         $this->buttons['view']['icon'] = $this->viewButtonIcon;
         $this->buttons['view']['options'] = array('class' => 'btn btn-mini btn-success');
     }
     if ($this->updateButtonIcon !== false && !isset($this->buttons['update']['icon'])) {
         $this->buttons['update']['icon'] = $this->updateButtonIcon;
         $this->buttons['update']['options'] = array('class' => 'btn btn-mini btn-info');
     }
     if ($this->deleteButtonIcon !== false && !isset($this->buttons['delete']['icon'])) {
         $this->buttons['delete']['icon'] = $this->deleteButtonIcon;
         $this->buttons['delete']['options'] = array('class' => 'btn btn-mini btn-danger');
     }
 }
コード例 #17
0
 public function init()
 {
     $themeUrl = Yii::app()->theme->baseUrl;
     $ctrl = Yii::app()->controller->id;
     $act = Yii::app()->controller->action->id;
     $this->deleteConfirmation = Yii::t('ui', 'Do you really want to delete this item?');
     $this->afterDelete = 'function(link,success,data){ if(success){ alertify.log("Record Deleted","success",7000); } }';
     if ($ctrl == 'i18n' && $act == 'admin') {
         $this->template = '{filter} {update} {delete}';
     } else {
         $this->template = '{update} {delete}';
     }
     $this->viewButtonImageUrl = $themeUrl . '/images/view16x16.png';
     $this->updateButtonImageUrl = $themeUrl . '/images/update16x16.png';
     $this->deleteButtonImageUrl = $themeUrl . '/images/delete16x16.png';
     return parent::init();
 }
コード例 #18
0
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         echo $this->filter;
     } else {
         if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false) {
             if (is_array($this->filter)) {
                 echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id' => false, 'prompt' => ''));
             } else {
                 if ($this->filter === null) {
                     echo CHtml::activeTextField($this->grid->filter, $this->name, array('id' => false));
                 }
             }
         } else {
             parent::renderFilterCellContent();
         }
     }
 }
コード例 #19
0
 /**
  *### .initDefaultButtons()
  *
  * Initializes the default buttons (view, update and delete).
  */
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     if ($this->viewButtonIcon !== false && !isset($this->buttons['view']['icon'])) {
         $this->buttons['view']['icon'] = $this->viewButtonIcon;
     }
     if ($this->updateButtonIcon !== false && !isset($this->buttons['update']['icon'])) {
         $this->buttons['update']['icon'] = $this->updateButtonIcon;
     }
     if ($this->deleteButtonIcon !== false && !isset($this->buttons['delete']['icon'])) {
         $this->buttons['delete']['icon'] = $this->deleteButtonIcon;
     }
     if (isset($this->buttons['headerAction'])) {
         // Make this to support multiple "actions" so that this mess doesnt take place?
         $options = $this->buttons['headerAction']['options'];
         $this->filterCellContent = CHtml::link('<i class="icon-' . $this->buttons['headerAction']['icon'] . '"></i>', $this->buttons['headerAction']['url'], $this->buttons['headerAction']['options']);
     }
 }
コード例 #20
0
ファイル: MyGridView.php プロジェクト: xPashaNx/diet
	function __construct($grid) {
		parent::__construct($grid);

		$this->buttons=array
					(
						'view' => array
						(
							'imageUrl'=>'/images/admin/view_grid.png',
						),
						'update' => array
						(
							'imageUrl'=>'/images/admin/edit.png',
						),
						'delete' => array
						(
							'imageUrl'=>'/images/admin/del.png',
						),
					);

	}
コード例 #21
0
 /**
  * Initializes the default buttons (view, update and delete).
  */
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     if ($this->viewButtonIcon !== false && !isset($this->buttons['view']['icon'])) {
         $this->buttons['view']['icon'] = $this->viewButtonIcon;
     }
     if ($this->updateButtonIcon !== false && !isset($this->buttons['update']['icon'])) {
         $this->buttons['update']['icon'] = $this->updateButtonIcon;
     }
     if ($this->deleteButtonIcon !== false && !isset($this->buttons['delete']['icon'])) {
         $this->buttons['delete']['icon'] = $this->deleteButtonIcon;
     }
     $temp = $this->buttons['view']['url'];
     $temp = substr_replace($temp, $this->grid->filter->tableSchema->name . '/', 35, 0);
     $this->buttons['view']['url'] = $temp;
     $temp = $this->buttons['update']['url'];
     $temp = substr_replace($temp, $this->grid->filter->tableSchema->name . '/', 35, 0);
     $this->buttons['update']['url'] = $temp;
     $temp = $this->buttons['delete']['url'];
     $temp = substr_replace($temp, $this->grid->filter->tableSchema->name . '/', 35, 0);
     $this->buttons['delete']['url'] = $temp;
 }
コード例 #22
0
ファイル: EJuiDlgsColumn.php プロジェクト: cicb/tpc
 /**
  * Initialize the column.
  * Override the view and update buttons
  */
 public function init()
 {
     if ($this->viewDialogEnabled) {
         $this->initViewButton();
         $this->renderViewDialogWidget();
     }
     if ($this->updateDialogEnabled) {
         $this->initUpdateButton();
         $this->renderUpdateDialogWidget();
     }
     parent::init();
 }
コード例 #23
0
    /**
     * Initializes the default buttons (view, update and delete).
     */
    protected function initDefaultButtons()
    {
        if (!$this->grid->bootstrap) {
            $this->viewButtonIcon = 'search';
        }
        if ($this->deleteConfirmation === null) {
            $this->deleteConfirmation = Yii::t('zii', 'Are you sure you want to delete this item?');
        }
        if (!isset($this->buttons['delete']['click'])) {
            if (is_string($this->deleteConfirmation)) {
                $confirmation = "if(!confirm(" . CJavaScript::encode($this->deleteConfirmation) . ")) return false;";
            } else {
                $confirmation = '';
            }
            if (Yii::app()->request->enableCsrfValidation) {
                $csrfTokenName = Yii::app()->request->csrfTokenName;
                $csrfToken = Yii::app()->request->csrfToken;
                $csrf = "\n\t\tdata:{ '{$csrfTokenName}':'{$csrfToken}' },";
            } else {
                $csrf = '';
            }
            if ($this->afterDelete === null) {
                $this->afterDelete = 'function(){}';
            }
            $this->buttons['delete']['click'] = <<<JavaScript
function() {
\t{$confirmation}
\t\$.getJSON(\$(this).attr('href'), function(){
\t\tjQuery('#{$this->grid->id}').eDataTables('refresh');
\t});
\treturn false;
}
JavaScript;
        }
        parent::initDefaultButtons();
        // history button
        if ($this->historyButtonLabel === null) {
            $this->historyButtonLabel = Yii::t('EDataTables.edt', 'History');
        }
        if ($this->historyButtonImageUrl === null) {
            $this->historyButtonImageUrl = $this->grid->baseScriptUrl . '/history.png';
        }
        $button = array('label' => $this->historyButtonLabel, 'url' => $this->historyButtonUrl, 'imageUrl' => $this->historyButtonImageUrl, 'options' => $this->historyButtonOptions);
        if (isset($this->buttons['history'])) {
            $this->buttons['history'] = array_merge($button, $this->buttons['history']);
        } else {
            $this->buttons['history'] = $button;
        }
        if ($this->viewButtonIcon !== false && !isset($this->buttons['view']['icon'])) {
            $this->buttons['view']['icon'] = $this->viewButtonIcon;
        }
        if ($this->updateButtonIcon !== false && !isset($this->buttons['update']['icon'])) {
            $this->buttons['update']['icon'] = $this->updateButtonIcon;
        }
        if ($this->deleteButtonIcon !== false && !isset($this->buttons['delete']['icon'])) {
            $this->buttons['delete']['icon'] = $this->deleteButtonIcon;
        }
        if ($this->historyButtonIcon !== false && !isset($this->buttons['history']['icon'])) {
            $this->buttons['history']['icon'] = $this->historyButtonIcon;
        }
    }
コード例 #24
0
ファイル: ButtonColumn.php プロジェクト: buildshop/bs-common
 public function renderHeaderCell()
 {
     $this->headerHtmlOptions['width'] = 'auto';
     parent::renderHeaderCell();
 }
コード例 #25
0
 protected function renderButton($id, $button, $row, $data)
 {
     $button['imageUrl'] = Yii::app()->baseUrl . '/images/' . Contrato::getReajusta($data->id) . '.png';
     parent::renderButton($id, $button, $row, $data);
 }
コード例 #26
0
ファイル: ExtGridView.php プロジェクト: rash012/cms
 /**
  * Initialization
  */
 public function init()
 {
     $this->buttons = CMap::mergeArray($this->buttons, array('view' => array('imageUrl' => '/images/admin/view_grid.png'), 'update' => array('imageUrl' => '/images/admin/edit.png'), 'delete' => array('imageUrl' => '/images/admin/del.png')));
     parent::init();
 }
コード例 #27
0
 public function getDataCellContent($row)
 {
     if (method_exists(get_parent_class($this), 'getDataCellContent')) {
         return parent::getDataCellContent($row);
     }
     ob_start();
     $this->renderDataCellContent($row, $this->grid->dataProvider->data[$row]);
     return ob_get_clean();
 }
コード例 #28
0
ファイル: X2ButtonColumn.php プロジェクト: dsyman2/X2CRM
 /**
  * Initializes the default buttons (view, update and delete).
  */
 protected function initDefaultButtons()
 {
     $this->viewButtonLabel = "<span class='fa fa-search' title='" . CHtml::encode(Yii::t('app', 'View record')) . "'>\n             </span>";
     $this->updateButtonLabel = "<span class='fa fa-edit' title='" . CHtml::encode(Yii::t('app', 'Edit record')) . "'>\n             </span>";
     $this->deleteButtonLabel = "<span class='fa fa-times x2-delete-icon' \n              title='" . CHtml::encode(Yii::t('app', 'Delete record')) . "'></span>";
     parent::initDefaultButtons();
 }
コード例 #29
0
    public function init()
    {
        //initializ variables
        $_customJS = null;
        $_beforeAjax = null;
        $_click = null;
        $_visible = null;
        $_options = null;
        $_imageUrl = null;
        //define defaults
        $_optionsDefault = array('class' => 'clear', 'id' => 'cbcwr_clear', 'style' => 'text-align:center;display:block;');
        // handle custom JS setup
        if (!empty($this->onClick_BeforeClear)) {
            $_customJS = $this->onClick_BeforeClear . ';';
        }
        if (!empty($this->onClick_AfterClear)) {
            $_beforeAjax = $this->onClick_AfterClear . ";\r\n";
        }
        // turn custom setup into representative output
        $_click = "js:function() {{$_customJS} return cbcwr_clearFields() }";
        $_visible = is_bool($this->clearVisible) ? $this->clearVisible ? 'true' : 'false' : $this->clearVisible;
        if (empty($this->clearHtmlOptions)) {
            $this->clearHtmlOptions = array();
        }
        $_options = @array_merge($_optionsDefault, $this->clearHtmlOptions);
        if (!empty($this->imageUrl)) {
            $_imageUrl = $this->imageUrl;
        } else {
            $_imageUrl = $this->grid->baseScriptUrl . '/delete.png';
        }
        if (!empty($this->url)) {
            $_url = $this->url;
        } else {
            $_url = 'Yii::app()->controller->createUrl(Yii::app()->controller->action->ID,array("clearFilters"=>1))';
        }
        if (!empty($this->label)) {
            $_label = Yii::t('app', $this->label);
        } else {
            $_label = Yii::t('app', 'Clear Filters');
        }
        // define the button structure to be used
        $this->_clearButton = array('label' => $_label, 'url' => $_url, 'imageUrl' => $_imageUrl, 'options' => $_options, 'click' => $_click, 'visible' => $_visible);
        $this->buttons = CMap::mergeArray($this->buttons, array('clear' => $this->_clearButton));
        $this->_templateB = $this->template;
        $this->template .= "{clear}";
        $script = <<<HTMLEND
\$.fn.clearFields = \$.fn.clearInputs = function() {
    return this.each(function() {
        var t = this.type, tag = this.tagName.toLowerCase();
        if (t == 'text' || t == 'password' || tag == 'textarea') {
            this.value = '';
        }
        else if (t == 'checkbox' || t == 'radio') {
            this.checked = false;
        }
        else if (tag == 'select') {
            this.selectedIndex = -1;
        }
    });
};
        
function cbcwr_clearFields() {
    try
    {    
        \$('#{$this->grid->id} :input').clearFields(); // this will clear all input in the current grid
        {$_beforeAjax} \$('#{$this->grid->id} .{$this->grid->filterCssClass} :input').first().trigger('change');// to submit the form
        return false;
    }
    catch(cbwr_err)
    {
        return false;
    }
}
HTMLEND;
        Yii::app()->clientScript->registerScript(__CLASS__ . 'clearFields', $script, CClientScript::POS_HEAD);
        // call parent to initialize other buttons
        parent::init();
    }
コード例 #30
0
 protected function renderButton($id, $button, $row, $data)
 {
     $button['imageUrl'] = $data->validado == "1" ? Yii::app()->baseUrl . "/images/validated.png" : Yii::app()->baseUrl . "/images/not_validated.png";
     parent::renderButton($id, $button, $row, $data);
 }