To add an ActionColumn to the gridview, add it to the [[GridView::columns|columns]] configuration as follows: php 'columns' => [ ... [ 'class' => 'yii\grid\ActionColumn', you may configure additional properties here ], ]
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends Column
コード例 #1
1
ファイル: ActionColumn.php プロジェクト: huasxin/lulucms2
 public function init()
 {
     parent::init();
     $this->headerOptions['width'] = '120px';
     
     $this->template = '{update} {delete}';
 }
コード例 #2
0
ファイル: UserRoleColumn.php プロジェクト: anli/yii2-rbac
 /**
  * @return string $template
  * @return mixed
  */
 public function actions($template = '{update} {delete}')
 {
     $this->columns = array_merge($this->columns, [['class' => ActionColumn::className(), 'controller' => SELF::CONTROLLER, 'template' => $template, 'buttons' => ['update' => function ($url, $model, $key) {
         return Html::a('<i class="fa fa-pencil"></i>', false, ['value' => Url::to([SELF::CONTROLLER . '/update', 'id' => $model->id]), 'title' => 'Update', 'class' => 'showModalButton']);
     }], 'contentOptions' => ['class' => 'text-right']]]);
     return $this;
 }
コード例 #3
0
 public function createUrl($action, $model, $key, $index)
 {
     if (method_exists($model, 'getUrl') && ($url = $model->getUrl($action)) && !$this->urlCreator) {
         return $url;
     } else {
         return parent::createUrl($action, $model, $key, $index);
     }
 }
コード例 #4
0
ファイル: ActionColumn.php プロジェクト: hucongyang/lulucms2
 public function init()
 {
     parent::init();
     if (!isset($this->headerOptions['width'])) {
         $this->headerOptions['width'] = $this->width;
     }
     $this->contentOptions = ['class' => 'da-icon-column', 'style' => 'width:' . $this->width . ';'];
 }
コード例 #5
0
ファイル: ActionColumnCustom.php プロジェクト: hysdop/YobaCMS
 /**
  * Initializes the default button rendering callbacks.
  */
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     if (!isset($this->buttons['active'])) {
         $this->buttons['active'] = function ($url, $model) {
             return Html::a('<span onclick="admin_api.request({id:' . $model['id'] . ', model:\'' . lcfirst((new \ReflectionClass($model))->getShortName()) . '\', method:\'post\', attributes:{active:' . ($model['active'] ? '0' : '1') . '}})" class="glyphicon ' . ($model['active'] ? 'glyphicon-ok' : 'glyphicon-ban-circle') . ' " style="color: ' . ($model['active'] ? 'yellow' : 'gray') . ' "></span>', '', ['title' => $model['active'] ? 'Отключить' : 'Включить']);
         };
     }
 }
コード例 #6
0
 public function init()
 {
     parent::init();
     if (is_array($this->params)) {
         $this->params = '&' . http_build_query($this->params);
     } else {
         $this->params = '&' . http_build_query(['ref' => Yii::$app->getRequest()->get('id')]);
     }
 }
コード例 #7
0
 public function init()
 {
     $this->header = $this->header ?: Module::t('Actions');
     $this->footer = $this->footer ?: Module::t('Actions');
     $this->headerOptions = ArrayHelper::merge(['class' => 'text-align-center', 'width' => '100'], $this->headerOptions);
     $this->footerOptions = ArrayHelper::merge(['class' => 'text-align-center font-weight-bold th'], $this->footerOptions);
     $this->contentOptions = ArrayHelper::merge(['class' => 'text-align-center nowrap'], $this->contentOptions);
     parent::init();
 }
コード例 #8
0
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     if (!isset($this->buttons['form-view'])) {
         $this->buttons['form-view'] = function ($url, $model, $key) {
             $options = array_merge(['title' => Yii::t('yii', 'Add'), 'aria-label' => Yii::t('yii', 'Add'), 'data-pjax' => '0'], $this->buttonOptions);
             return Html::a('<span class="glyphicon glyphicon-wrench"></span>', $url, $options);
         };
     }
 }
コード例 #9
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->buttons['update'] = function ($url, $model) {
         return Html::a('<i class="fa fa-pencil"></i> Edit', $url, ['title' => Yii::t('yii', 'Update'), 'data-pjax' => '0', 'class' => 'btn btn-primary btn-xs']);
     };
     $this->buttons['delete'] = function ($url, $model) {
         return Html::a('<i class="fa fa-trash-o"></i> Delete', $url, ['title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0', 'class' => 'btn btn-primary btn-xs']);
     };
 }
コード例 #10
0
ファイル: ApiUserColumn.php プロジェクト: anli/yii2-auth0
 /**
  * @param string $template
  * @param mixed $params
  * @return mixed
  */
 public function actions($template = '{update} {delete}', $params = '')
 {
     $this->columns = array_merge($this->columns, [['class' => ActionColumn::className(), 'controller' => SELF::CONTROLLER, 'template' => $template, 'buttons' => ['update-role-to-user' => function ($url, $model, $key) use($params) {
         return Html::a('<i class="fa fa-check"></i>', [SELF::CONTROLLER . '/update-role', 'userId' => $model['user_id'], 'tenantId' => $params, 'role' => 'user'], ['title' => 'Update to User', 'data-toggle' => 'tooltip']);
     }, 'update-role-to-admin' => function ($url, $model, $key) use($params) {
         return Html::a('<i class="fa fa-check-circle"></i>', [SELF::CONTROLLER . '/update-role', 'userId' => $model['user_id'], 'tenantId' => $params, 'role' => 'admin'], ['title' => 'Update to Admin', 'data-toggle' => 'tooltip']);
     }, 'remove-tenant' => function ($url, $model, $key) {
         return Html::a('<i class="fa fa-times"></i>', [SELF::CONTROLLER . '/remove-tenant', 'userId' => $model['user_id']], ['title' => 'Remove', 'data-toggle' => 'tooltip']);
     }], 'contentOptions' => ['class' => 'text-right']]]);
     return $this;
 }
コード例 #11
0
 /**
  * @inheritdoc
  */
 protected function renderFilterCellContent()
 {
     if ($this->gridType == 'datatable') {
         if (is_string($this->filter)) {
             return $this->filter;
         } elseif ($this->filter === true) {
             // default search and reset button for all filters
             return '<div class="margin-bottom-5"><button class="btn btn-sm blue filter-submit margin-bottom"><i class="fa fa-search"></i> Search</button></div><button class="btn btn-sm red filter-cancel"><i class="fa fa-times"></i> Reset</button>';
         }
     }
     return parent::renderFilterCellContent();
 }
コード例 #12
0
ファイル: Column.php プロジェクト: anli/yii2-helper
 /**
  * @return string $template
  * @return mixed
  */
 public function actions($template = '{update} {delete}')
 {
     $this->columns = array_merge($this->columns, [['class' => ActionColumn::className(), 'controller' => $this->controller, 'template' => $template, 'buttons' => ['ajax-update' => function ($url, $model) {
         return Html::a(Html::tag('i', '', ['class' => 'glyphicon glyphicon-pencil']), false, ['value' => Url::to(["{$this->controller}/ajax-update", 'id' => $model->id, 'pjaxId' => 'list-pjax']), 'data-toggle' => 'tooltip', 'title' => 'Update', 'class' => 'showModalButton', 'name' => "update-{$this->controller}-button"]);
     }, 'ajax-delete' => function ($url, $model) {
         AjaxDeleteAsset::register(Yii::$app->controller->view);
         return Html::a('<span  class="glyphicon glyphicon-trash"></span>', false, ['class' => 'ajaxDelete', 'delete-url' => Url::to(["{$this->controller}/ajax-delete", 'id' => $model->id]), 'pjax-container' => 'list-pjax', 'name' => "delete-{$this->controller}-button"]);
     }, 'ajax-copy' => function ($url, $model) {
         return Html::a(Html::tag('i', '', ['class' => 'glyphicon glyphicon-copy']), false, ['value' => Url::to(["{$this->controller}/ajax-copy", 'id' => $model->id, 'pjaxId' => 'list-pjax']), 'data-toggle' => 'tooltip', 'title' => 'Copy', 'class' => 'showModalButton', 'name' => "copy-{$this->controller}-button"]);
     }], 'contentOptions' => ['class' => 'text-right']]]);
     return $this;
 }
コード例 #13
0
 protected function renderDataCellContent($model, $key, $index)
 {
     $dropdownId = $this->grid->getId() . '-dropdown2-menu-' . $index;
     $this->template = implode(' ', array_keys(array_filter(['<li>{view}</li>' => ModelHelper::canRead($model), '<li>{update}</li>' => ModelHelper::canUpdate($model), '<li>{delete}</li>' => ModelHelper::canDelete($model)])));
     $fix = ['~(glyphicon\\-eye\\-open"\\>\\</span\\>)(\\</a\\>)~i' => '$1 ' . Yii::t('mozayka', 'View') . '$2', '~(glyphicon\\-pencil"\\>\\</span\\>)(\\</a\\>)~i' => '$1 ' . Yii::t('mozayka', 'Update') . '$2', '~(glyphicon\\-trash"\\>\\</span\\>)(\\</a\\>)~i' => '$1 ' . Yii::t('mozayka', 'Delete') . '$2', '~\\s+title\\="[^"]*"~i' => '', '~\\s+data\\-confirm\\="[^"]*"~i' => '', '~\\s+data\\-method\\="[^"]*"~i' => ''];
     $cellContent = preg_replace(array_keys($fix), array_values($fix), parent::renderDataCellContent($model, $key, $index));
     // dropdown2-menu
     if ($cellContent && $cellContent != $this->grid->emptyCell) {
         $cellContent = Html::button('<span class="glyphicon glyphicon-cog"></span>', ['title' => Yii::t('mozayka', 'Actions'), 'class' => 'btn btn-default btn-xs', 'data-dropdown2' => '#' . $dropdownId]) . Html::tag('div', Html::tag('ul', $cellContent, ['class' => 'dropdown2-menu']), ['id' => $dropdownId, 'class' => 'dropdown2 dropdown2-tip' . (array_search($this, $this->grid->columns) + 1 > count($this->grid->columns) / 2 ? ' dropdown2-anchor-right' : '')]);
     }
     return $cellContent;
 }
コード例 #14
0
ファイル: Grid.php プロジェクト: dawei101/yii2-admin-module
 /**
  * List of grid actions
  * @return array
  */
 public function actions()
 {
     $entity = \Yii::$app->getRequest()->getQueryParam('entity', null);
     $primaryKey = $this->entity->primaryKey();
     return [['class' => ActionColumn::className(), 'buttons' => ['view' => function ($url, $model, $key) use($entity, $primaryKey) {
         return Html::a(Yii::t('admin', 'View'), ['manage/view', 'entity' => $entity, 'id' => $model->{$primaryKey}], ['class' => 'btn btn-primary']);
     }, 'update' => function ($url, $model, $key) use($entity, $primaryKey) {
         return Html::a(Yii::t('admin', 'Edit'), ['manage/update', 'entity' => $entity, 'id' => $model->{$primaryKey}], ['class' => 'btn btn-warning']);
     }, 'delete' => function ($url, $model, $key) use($entity, $primaryKey) {
         return Html::a(Yii::t('admin', 'Delete'), ['manage/delete', 'entity' => $entity, 'id' => $model->{$primaryKey}], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('admin', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
     }]]];
 }
コード例 #15
0
ファイル: UserColumn.php プロジェクト: anli/yii2-rbac
 /**
  * @return string $template
  * @return mixed
  */
 public function actions($template = '{update} {delete}')
 {
     $this->columns = array_merge($this->columns, [['class' => ActionColumn::className(), 'controller' => SELF::CONTROLLER, 'template' => $template, 'buttons' => ['update-user-role' => function ($url, $model, $key) {
         if ($model->getUserRole()->exists()) {
             return Html::a('<i class="fa fa-pencil"></i>', false, ['value' => Url::to([SELF::CONTROLLER . '/update', 'id' => $model->userRole->id]), 'title' => 'Update', 'class' => 'showModalButton']);
         }
         return Html::a('<i class="fa fa-plus"></i>', false, ['value' => Url::to([SELF::CONTROLLER . '/create', 'user_id' => $model->id]), 'title' => 'Create', 'class' => 'showModalButton']);
     }, 'delete-user-role' => function ($url, $model, $key) {
         if ($model->getUserRole()->exists()) {
             return Html::a('<i class="fa fa-trash"></i>', Url::to(['user-role/delete', 'id' => $model->userRole->id]), ['data-confirm' => 'Are you sure you want to delete this item?', 'data-method' => 'post', 'data-pjax' => '0']);
         }
         return '';
     }], 'contentOptions' => ['class' => 'text-right']]]);
     return $this;
 }
コード例 #16
0
    public function init(){

        $visibleColumn=$this->statusColumn;

        $this->buttons = [
            'update' => function($url,$model){
                return $this->updateButton($url,$model);
            },
            'view' => function($url,$model){
                return $this->viewButton($url,$model);
            },
            'delete' => function($url,$model) use ($visibleColumn){
                return ($model->hasAttribute($visibleColumn) && $model->$visibleColumn) ? $this->deleteButton($url,$model) : '';
            }
        ];
        parent::init();
    }
コード例 #17
0
ファイル: ActionColumn.php プロジェクト: ahb360/kalpok
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (!is_array($this->permissions)) {
         throw new InvalidConfigException('$permissions has to be an array of allowed permissions for each button.');
     }
     if (!empty($this->permissions)) {
         foreach ($this->permissions as $key => $allowedPermissions) {
             if (!$this->checkIfUserHas($allowedPermissions)) {
                 $this->buttons[$key] = function ($url, $model, $key) {
                     return;
                 };
             }
         }
     }
     parent::init();
     $this->initDefaultButtons();
 }
コード例 #18
0
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     if (!isset($this->actionName)) {
         $this->actionName = 'disable';
     }
     if (!isset($this->buttons[$this->actionName])) {
         $this->buttons[$this->actionName] = function ($url, $model, $key) {
             $label = $model->{$this->stateAttribute} ? Yii::t('app', 'Enable') : Yii::t('app', 'Disable');
             $options = array_merge($this->buttonOptions, ['title' => $label, 'aria-label' => $label, 'data-method' => 'post', 'data-pjax' => '0', 'class' => 'btn btn-block ' . ($model->{$this->stateAttribute} ? 'btn-success' : 'btn-danger')]);
             if (isset($this->confirmation)) {
                 $options['data-confirm'] = $this->confirmation;
             }
             return Html::a('<span class="glyphicon glyphicon-ban-circle"></span> ' . $label, $url, $options);
         };
     }
 }
コード例 #19
0
ファイル: ActionColumn.php プロジェクト: tsyrya/mybriop
 public function init()
 {
     parent::init();
     if (!isset($this->buttonOptions['class'])) {
         $this->buttonOptions['class'] = ['btn', 'btn-default', 'btn-action'];
     }
     if (!isset($this->header)) {
         $url = $this->createUrl('create', null, null, null);
         $this->header = $this->createButton($url, 'Создать', ['btn-create']);
     }
     /**
      * @param Kurs $model
      * @return bool
      */
     $this->visibleButtons['iup'] = function ($model) {
         return $model->tip === TipKursa::PP || $model->tip === TipKursa::PO;
     };
 }
コード例 #20
0
 /**
  * Initializes the default button rendering callbacks.
  */
 protected function initDefaultButtons()
 {
     ActionAsset::register($this->grid->view);
     parent::initDefaultButtons();
     if (!isset($this->buttons['up'])) {
         $this->buttons['up'] = function ($url) {
             $options = ArrayHelper::merge(['title' => Yii::t('hass', 'Up'), 'aria-label' => Yii::t('hass', 'Up'), 'data-pjax' => '0'], $this->buttonOptions);
             Html::addCssClass($options, "move-up");
             return Html::a('<span class="glyphicon glyphicon-arrow-up"></span>', $url, $options);
         };
     }
     if (!isset($this->buttons['down'])) {
         $this->buttons['down'] = function ($url) {
             $options = ArrayHelper::merge(['title' => Yii::t('hass', 'Down'), 'aria-label' => Yii::t('hass', 'Down'), 'data-pjax' => '0'], $this->buttonOptions);
             Html::addCssClass($options, "move-down");
             return Html::a('<span class="glyphicon glyphicon-arrow-down"></span>', $url, $options);
         };
     }
 }
コード例 #21
0
 /**
  * Renders the data cell.
  */
 protected function renderDataCellContent($model, $key, $index)
 {
     $content = parent::renderDataCellContent($model, $key, $index);
     $options = $this->dropdownButton;
     if ($this->_isDropdown) {
         $label = ArrayHelper::remove($options, 'label', Yii::t('kvgrid', 'Actions'));
         $caret = ArrayHelper::remove($options, 'caret', ' <span class="caret"></span>');
         $options = ArrayHelper::merge($options, ['type' => 'button', 'data-toggle' => 'dropdown']);
         Html::addCssClass($options, 'dropdown-toggle');
         $button = Html::button($label . $caret, $options);
         Html::addCssClass($this->dropdownMenu, 'dropdown-menu');
         $dropdown = $button . PHP_EOL . Html::tag('ul', $content, $this->dropdownMenu);
         return Html::tag('div', $dropdown, ['class' => 'dropdown']);
     }
     return $content;
 }
コード例 #22
0
ファイル: index.php プロジェクト: eibenm/raptorapp
/* @var $this yii\web\View */
/* @var $searchModel app\models\search\RaptorSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Raptors';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="raptor-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Create Raptor', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
Pjax::begin(['timeout' => Yii::$app->constants->pjaxTimeout]);
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'options' => ['class' => 'table-responsive'], 'columns' => [['class' => ActionColumn::className(), 'template' => '{update}{view}', 'headerOptions' => ['style' => 'width: 100px;'], 'buttonOptions' => ['style' => 'padding: 5px;'], 'contentOptions' => ['style' => 'text-align: center;']], 'species_short', 'species_long']]);
?>
    <?php 
Pjax::end();
?>

</div>
コード例 #23
0
ファイル: index.php プロジェクト: sieulog/yii2-cart
    <!-- Table row -->
    <div class="row">
        <div class="col-xs-12 table-responsive">
            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'layout' => "{items}\n{pager}", 'columns' => [['attribute' => 'no', 'label' => '#', 'value' => function ($model) {
    static $no;
    return ++$no;
}, 'headerOptions' => ['width' => '4%', 'style' => 'text-align: center'], 'contentOptions' => ['style' => 'text-align: center; vertical-align: middle;']], ['attribute' => 'name', 'format' => 'raw', 'label' => ' ' . Yii::t('cart', 'Description'), 'contentOptions' => ['style' => 'vertical-align: middle'], 'value' => function ($model) {
    return $model->icon . ' ' . $model->name . ' ' . Html::tag('span', $model->description, ['class' => 'text-muted']);
}], ['attribute' => 'quantity', 'value' => function ($model, $key, $index, $column) {
    return QuantityCell::widget(['model' => $model]);
    //, 'type' => 'number'
}, 'format' => 'raw'], ['attribute' => 'price', 'contentOptions' => ['style' => 'vertical-align: middle;white-space: nowrap;'], 'value' => function ($model) use($cart) {
    return $cart->formatCurrency($model->cost);
}], 'actions' => ['class' => ActionColumn::className(), 'template' => '{remove}', 'headerOptions' => ['width' => '4%'], 'contentOptions' => ['style' => 'text-align: center; vertical-align: middle;'], 'buttons' => ['remove' => function ($url, $model, $key) {
    return Html::a('<i class="fa fa-times text-danger"></i>', ['remove', 'id' => $model->id]);
}]]]]);
?>
        </div>
        <!-- /.col -->
    </div>
    <!-- /.row -->

    <div class="row">
        <!-- accepted payments column -->
        <div class="col-xs-6">
            <p class="lead">Payment Methods:</p>
            <img src="https://almsaeedstudio.com/themes/AdminLTE/dist/img/credit/visa.png" alt="Visa">
            <img src="https://almsaeedstudio.com/themes/AdminLTE/dist/img/credit/mastercard.png" alt="Mastercard">
            <img src="https://almsaeedstudio.com/themes/AdminLTE/dist/img/credit/american-express.png"
コード例 #24
0
ファイル: index.php プロジェクト: TF03/yii2-advanced-def
echo Alert::widget();
?>

<div class="accounts-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Новый счет', ['new'], ['class' => 'btn btn-success']);
?>
        <?php 
echo Html::a('Новый перевод', Yii::$app->urlManager->createUrl(['transaction/transfer']), ['class' => 'btn btn-info']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'showOnEmpty' => false, 'layout' => "{items}\n{pager}", 'filterModel' => $searchModel, 'columns' => ['name', 'amount', ['attribute' => 'currencyId', 'headerOptions' => ['width' => '100'], 'filter' => false, 'content' => function ($data) {
    /** @var $data \frontend\models\Accounts */
    if ($data->currency) {
        return $data->currency->title;
    }
    return false;
}], ['class' => ActionColumn::className(), 'template' => '{update}']]]);
?>

</div>
コード例 #25
0
 /**
  * Initializes the action column and triggers rendering of default buttons.
  * See [[initDefaultButtons]] for details.
  */
 public function init()
 {
     parent::init();
     $this->initDefaultButtons();
 }
コード例 #26
0
ファイル: index.php プロジェクト: cubiclab/store-cube
$this->title = Yii::t('storecube', 'PAGE_PRODUCTS');
$this->params['breadcrumbs'][] = $this->title;
?>

<?php 
$gridId = 'products-grid';
$panelButtons = $actions = [];
if (Yii::$app->user->can('ACPProductsCreate')) {
    $panelButtons[] = '{create}';
}
if (Yii::$app->user->can('ACPProductsUpdate')) {
    $actions[] = '{update}';
}
if (Yii::$app->user->can('ACPProductsDelete')) {
    $panelButtons[] = '{mass-delete}';
    $actions[] = '{delete}';
}
if (Yii::$app->user->can('ACPProductsView')) {
    $actions[] = '{view}';
}
$gridActionsColumn = ['class' => ActionColumn::className(), 'template' => implode(' ', $actions)];
$panelButtons = !empty($panelButtons) ? implode(' ', $panelButtons) : null;
?>

<?php 
Panel::begin(['title' => $this->title, 'buttonsTemplate' => $panelButtons, 'grid' => $gridId]);
?>

<?php 
echo GridView::widget(['id' => $gridId, 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => CheckboxColumn::classname()], 'article', 'name', 'short_desc:ntext', $gridActionsColumn], 'pager' => ['firstPageLabel' => 'First', 'lastPageLabel' => 'Last']]);
Panel::end();
コード例 #27
0
ファイル: index.php プロジェクト: HeavyDots/heavyCMS
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\grid\ActionColumn;
use dmstr\widgets\Alert;
$this->title = Yii::t('app', 'Blog Categories');
$this->params['breadcrumbs'][] = $this->title;
?>

<?php 
echo $this->render('_content-header');
?>

<?php 
echo Alert::widget();
?>

<p class="pull-left">
    <?php 
echo Html::a('<i class="glyphicon glyphicon-plus"></i> ' . Yii::t('app', 'Add New Blog Category'), 'create', ['class' => 'btn btn-primary']);
?>
</p>

<div class="clearfix"></div>

<?php 
echo GridView::widget(['dataProvider' => $blogCategoryProvider, 'filterModel' => $blogCategorySearch, 'id' => 'content-grid', 'tableOptions' => ['class' => 'table table-striped table-bordered box box-primary'], 'columns' => [['attribute' => 'name', 'format' => 'raw', 'value' => function ($blogCategory) {
    return Html::a($blogCategory->name, ['update', 'id' => $blogCategory->id]);
}], 'created_at:datetime', 'updated_at:datetime', ['class' => ActionColumn::className(), 'template' => '{update}']]]);
コード例 #28
0
ファイル: index.php プロジェクト: wsdslm/yii2-rbac
<?php

/**
 * @var yii\web\View $this
 * @var \yii\data\ActiveDataProvider $dataProvider
 * @var \ws\rbac\Module $module
 */
use yii\grid\ActionColumn;
use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\Pjax;
$this->title = Yii::$app->request->isPjax ? null : Yii::t('app', 'Assign');
$this->params['breadcrumbs'][] = $this->title;
$module = Yii::$app->controller->module;
?>

<div class="user-index">
    <?php 
Pjax::begin(['options' => ['id' => 'pjax']]);
?>
    <?php 
echo GridView::widget(['layout' => "{items}\n{summary}\n{pager}", 'dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', $module->usernameField, ['class' => ActionColumn::className(), 'template' => '{assign}', 'buttons' => ['assign' => function ($url, $model, $key) {
    $options = ['title' => Yii::t('yii', 'Assign'), 'aria-label' => Yii::t('yii', 'Assign'), 'data-pjax' => '0'];
    return Html::a('<span class="glyphicon glyphicon-user"></span>', ['assign', 'uid' => $model->id], $options);
}]]]]);
?>
    <?php 
Pjax::end();
?>
</div>
コード例 #29
0
ファイル: listRole.php プロジェクト: zhaoyan158567/galaxy
/*
 * This file is part of the Dektrium project.
 *
 * (c) Dektrium project <http://github.com/dektrium>
 *
 * For the full copyright and license information, please view the LICENSE.md
 * file that was distributed with this source code.
 */
/**
 * @var $dataProvider array
 * @var $filterModel  dektrium\rbac\models\Search
 * @var $this         yii\web\View
 */
use yii\grid\ActionColumn;
use kartik\grid\GridView;
use yii\helpers\Url;
$this->title = Yii::t('rbac', 'Roles');
$this->params['breadcrumbs'][] = $this->title;
$this->params['title'] = $this->title;
$this->params['menu']['auth'] = true;
$this->params['sub-menu']['list-role'] = true;
?>

<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $filterModel, 'layout' => "{items}\n{pager}", 'columns' => [['attribute' => 'name', 'header' => Yii::t('rbac', 'Name'), 'options' => ['style' => 'width: 20%']], ['attribute' => 'description', 'header' => Yii::t('rbac', 'Description'), 'options' => ['style' => 'width: 55%']], ['attribute' => 'rule_name', 'header' => Yii::t('rbac', 'Rule name'), 'options' => ['style' => 'width: 20%']], ['class' => ActionColumn::className(), 'template' => '{update} {delete}', 'urlCreator' => function ($action, $model) {
    return Url::to(['/auth/auth/' . $action, 'name' => $model['name']]);
}, 'options' => ['style' => 'width: 5%']]], 'export' => false, 'responsive' => true, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> ' . Yii::t('rbac', 'Roles') . '</h3>', 'type' => 'success', 'before' => false, 'footer' => false, 'after' => false]]);
?>

コード例 #30
0
ファイル: requests.php プロジェクト: shubnikofff/teleport
?>

    <div class="row">
        <div class="col-md-8">
            <?php 
echo $form->field($model, 'searchKey')->textInput(['placeholder' => 'Введите текст заявки'])->label(false);
?>
        </div>
        <div class="col-md-4" style="vertical-align: bottom">
            <?php 
echo Html::submitButton('<span class="glyphicon glyphicon-search"></span> Найти', ['class' => 'btn btn-primary']);
?>
        </div>
    </div>

    <?php 
ActiveForm::end();
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'tableOptions' => ['class' => 'table'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'topic', 'content' => function ($model) {
    return Html::a($model->topic, ['vks-request/view', 'id' => (string) $model->primaryKey]);
}, 'contentOptions' => ['style' => 'width: 62%']], ['attribute' => 'status', 'value' => function ($model) {
    return Request::statusName($model->status);
}, 'contentOptions' => ['style' => 'width: 13%']], ['attribute' => 'date', 'content' => function ($model) {
    return Yii::$app->formatter->asDate($model->date->sec) . " c {$model->beginTimeString} по {$model->endTimeString}";
}, 'contentOptions' => ['style' => 'width: 20%']], ['class' => \yii\grid\ActionColumn::className(), 'controller' => 'vks-request', 'template' => '{delete}', 'visible' => Yii::$app->user->can(SystemPermission::DELETE_REQUEST)]]]);
?>

</div>