當前位置: 首頁>>代碼示例>>PHP>>正文


PHP grid\Column類代碼示例

本文整理匯總了PHP中yii\grid\Column的典型用法代碼示例。如果您正苦於以下問題:PHP Column類的具體用法?PHP Column怎麽用?PHP Column使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Column類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: renderHeaderCellContent

 /**
  * Renders the header cell content.
  * The default implementation simply renders [[header]].
  * This method may be overridden to customize the rendering of the header cell.
  * @return string the rendering result
  */
 protected function renderHeaderCellContent()
 {
     $name = rtrim($this->name, '[]') . '_all';
     $id = $this->grid->options['id'];
     $options = json_encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name]);
     $this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});");
     if ($this->header !== null || !$this->multiple) {
         return parent::renderHeaderCellContent();
     } else {
         return Html::checkBox($name, false, ['class' => 'select-on-check-all']);
     }
 }
開發者ID:lianghongle,項目名稱:yii2-zh-cn,代碼行數:18,代碼來源:CheckboxColumn.php

示例2: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     /* @var $dataProvider ActiveDataProvider */
     $dataProvider = $this->grid->dataProvider;
     if (!$dataProvider instanceof ActiveDataProvider) {
         throw new InvalidConfigException('SortableColumn works only with ActiveDataProvider.');
     }
     if (!$this->gridContainerId) {
         throw new InvalidConfigException('$gridContainerId property must be set.');
     }
     Yii::setAlias('@sortable', dirname(__DIR__));
     Yii::$app->i18n->translations['sortable'] = ['class' => PhpMessageSource::className(), 'basePath' => '@sortable/messages'];
     /* @var $query \yii\db\ActiveQuery */
     $query = $dataProvider->query;
     $this->_model = new $query->modelClass();
     $this->contentOptions = function ($model) {
         /* @var $model ActiveRecord|BaseNumericalSortableBehavior */
         return ['class' => 'sortable-cell', 'data-position' => $model->getSortablePosition()];
     };
     if (!$this->header) {
         $this->header = Yii::t('sortable', 'Sort');
     }
     $this->visible = $this->isVisible();
     if (!$this->template) {
         $this->template = '<div class="sortable-section">{currentPosition}</div>
         <div class="sortable-section">{moveWithDragAndDrop}</div>
         <div class="sortable-section">{moveForward} {moveBack}</div>
         <div class="sortable-section">{moveAsFirst} {moveAsLast}</div>';
     }
     $this->initDefaultButtons();
     if (!Yii::$app->request->isAjax) {
         $this->registerJs();
     }
 }
開發者ID:arogachev,項目名稱:yii2-sortable,代碼行數:38,代碼來源:SortableColumn.php

示例3: renderFilterCellContent

 protected function renderFilterCellContent()
 {
     $filter = $this->guessFilter();
     if ($filter instanceof BaseFilter) {
         return $filter->render();
     }
     return Column::renderFilterCellContent();
 }
開發者ID:omnilight,項目名稱:yz2-admin,代碼行數:8,代碼來源:DataColumn.php

示例4: renderHeaderCellContent

 /**
  * Renders the header cell content.
  * The default implementation simply renders [[header]].
  * This method may be overridden to customize the rendering of the header cell.
  * @return string the rendering result
  */
 protected function renderHeaderCellContent()
 {
     if ($this->gridType == 'datatable-select') {
         if ($this->header !== null || !$this->multiple) {
             return Column::renderHeaderCellContent();
         } else {
             $name = rtrim($this->name, '[]') . '_all';
             return Html::checkBox($name, false, ['class' => 'group-checkable']);
         }
     } else {
         return parent::renderHeaderCellContent();
     }
 }
開發者ID:fangface,項目名稱:yii2-concord,代碼行數:19,代碼來源:CheckboxColumn.php

示例5: function

    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Создать номер', ['create'], ['class' => 'btn btn-success']);
?>
        <?php 
echo Html::a('Загрузить из файла', ['uploadform'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
$cols = [['class' => 'yii\\grid\\SerialColumn'], 'id', 'voip_number', ['attribute' => 'secret', 'value' => function ($model) {
    return Html::a($model->secret ? '* * *' : '', '', ['title' => $model->secret]);
}, 'format' => 'raw'], 'description', 'context', ['class' => Column::className(), 'content' => function ($model) use($id_wp) {
    return Html::a('Выбрать', ['voipnumbers/choicewp', 'id' => $model->id, 'id_wp' => $id_wp]);
}], ['class' => 'yii\\grid\\ActionColumn']];
if (!isset($id_wp)) {
    unset($cols[6]);
}
?>


    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $cols]);
?>

</div>
開發者ID:Griff19,項目名稱:it_base,代碼行數:30,代碼來源:index.php

示例6: function

<?php

/**
 * User: ivan
 * Date: 09.02.2016
 * Time: 12:31
 *
 * @var $this yii\web\View
 * @var $dp yii\data\ActiveDataProvider
 */
use yii\grid\GridView;
use yii\helpers\Html;
use yii\grid\Column;
use backend\models\Devices;
$this->title = '' . $title;
$this->params['breadcrumbs'][] = ['label' => 'Отчет', 'url' => ['reports/aindex']];
$this->params['breadcrumbs'][] = $this->title;
echo 'Отчет по устройству';
echo '<h1>' . $title . '</h1>';
echo GridView::widget(['dataProvider' => $dp, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'branch_id', 'label' => 'Подразделение'], ['attribute' => 'workplaces_title', 'label' => 'Рабочее место', 'value' => function ($dp) {
    return Html::a($dp['workplaces_title'], ['workplaces/view', 'id' => $dp['workplace_id']]);
}, 'format' => 'raw'], ['class' => Column::className(), 'header' => 'Кол-во', 'content' => function ($dp) use($type_id) {
    return Devices::getCountOnWp($type_id, $dp['workplace_id']);
}], ['attribute' => 'snp', 'label' => 'Ответственное лицо'], ['attribute' => 'job_title', 'label' => 'Должность'], ['attribute' => 'date', 'label' => 'Дата']]]);
開發者ID:Griff19,項目名稱:it_base,代碼行數:24,代碼來源:a_employee.php

示例7: renderHeaderCellContent

 /**
  * Renders the header cell content.
  * The default implementation simply renders [[header]].
  * This method may be overridden to customize the rendering of the header cell.
  * @return string the rendering result
  */
 protected function renderHeaderCellContent()
 {
     $name = $this->name;
     if (substr_compare($name, '[]', -2, 2) === 0) {
         $name = substr($name, 0, -2);
     }
     if (substr_compare($name, ']', -1, 1) === 0) {
         $name = substr($name, 0, -1) . '_all]';
     } else {
         $name .= '_all';
     }
     $id = $this->grid->options['id'];
     $options = json_encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     $this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});");
     if ($this->header !== null || !$this->multiple) {
         return parent::renderHeaderCellContent();
     } else {
         return Html::checkBox($name, false, ['class' => 'select-on-check-all']);
     }
 }
開發者ID:sx-dev,項目名稱:court,代碼行數:26,代碼來源:CheckboxColumn.php

示例8: renderHeaderCellContent

 /**
  * Renders the header cell content.
  * The default implementation simply renders [[header]].
  * This method may be overridden to customize the rendering of the header cell.
  * @return string the rendering result
  */
 protected function renderHeaderCellContent()
 {
     $name = rtrim($this->name, '[]') . '_all';
     $id = $this->grid->options['id'];
     $options = json_encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     $this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});");
     if ($this->header !== null || !$this->multiple) {
         return parent::renderHeaderCellContent();
     } else {
         //            return Html::checkBox($name, false, ['class' => 'select-on-check-all']);
         return "<label class=\"control-label\">" . Html::checkBox($name, false, ['class' => 'select-on-check-all']) . "<span class=\"text\"></span></label>";
     }
 }
開發者ID:lurongze,項目名稱:uii20160328,代碼行數:19,代碼來源:CheckboxColumn.php

示例9: init

 /**
  * @inheritdoc
  * @throws \yii\base\InvalidConfigException if [[name]] is not set.
  */
 public function init()
 {
     parent::init();
     if (empty($this->name)) {
         throw new InvalidConfigException('The "name" property must be set.');
     }
 }
開發者ID:kilyanov,項目名稱:yii2,代碼行數:11,代碼來源:RadioButtonColumn.php

示例10: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $script = '
     $(document).ready(function(){
         function hideFirstLast() {
             $(\'.sort-up, .sort-down\').show();
             $(\'.sort-up\').first().hide();
             $(\'.sort-down\').last().hide();
         }
         function refresh() {
             $(\'#' . $this->grid->id . '\').yiiGridView("applyFilter");
             hideFirstLast();
         }
         $(\'.sort-up\').on(\'click\', function(){
             var id = $(this).parent().parent().attr(\'data-key\');
             $.post("' . Url::toRoute(['swap']) . '?id="+id+"&dir=up").always(refresh);
             return false;
         });
         $(\'.sort-down\').on(\'click\' ,function(){
             var id = $(this).parent().parent().attr(\'data-key\');
             $.post("' . Url::toRoute(['swap']) . '?id="+id+"&dir=down").always(refresh);
             return false;
         });
         hideFirstLast();
     });';
     $this->grid->getView()->registerJs($script);
 }
開發者ID:alisherdavronov,項目名稱:yii2-grid-sort-column-enh,代碼行數:31,代碼來源:SortColumn.php

示例11: init

 /**
  * Initializes the object.
  * This method is invoked at the end of the constructor after the object is initialized with the
  * given configuration.
  */
 public function init()
 {
     if ($this->defaultItems) {
         $this->defaultItems = [['label' => Yii::t('yii', 'Update'), 'url' => ['update', 'id' => '{id}']], ['label' => Yii::t('yii', 'View'), 'url' => ['view', 'id' => '{id}']], ['label' => Yii::t('yii', 'Delete'), 'url' => ['delete', 'id' => '{id}']]];
     }
     parent::init();
 }
開發者ID:zulkifl,項目名稱:yii2-dropdown-action-column-1,代碼行數:12,代碼來源:DropDownActionColumn.php

示例12: init

 public function init()
 {
     parent::init();
     $this->defaultButtons = [['url' => 'edit', 'icon' => 'pencil', 'class' => 'btn-primary', 'label' => Yii::t('app', 'Edit')], ['url' => 'delete', 'icon' => 'trash-o', 'class' => 'btn-danger', 'label' => Yii::t('app', 'Delete'), 'options' => ['data-action' => 'delete']]];
     if (null === $this->buttons) {
         $this->buttons = $this->defaultButtons;
     } elseif ($this->buttons instanceof Closure) {
         $this->callbackButtons = $this->buttons;
     }
 }
開發者ID:tqsq2005,項目名稱:dotplant2,代碼行數:10,代碼來源:ActionColumn.php

示例13: renderHeaderCellContent

 /**
  * @inheritdoc
  */
 protected function renderHeaderCellContent()
 {
     if ($this->label !== null) {
         return $this->label;
     }
     if ($this->attribute !== null) {
         $model = $this->grid->filterModel;
         return $model->getAttributeLabel($this->attribute);
     }
     return parent::renderHeaderCell();
 }
開發者ID:wrt54gl,項目名稱:yii2-tabular,代碼行數:14,代碼來源:InputColumn.php

示例14: init

 /**
  * @inheritDoc
  */
 public function init()
 {
     parent::init();
     /**
      * @var ActiveDataProvider $provider
      * @var ActiveQuery        $query
      */
     $provider = $this->grid->dataProvider;
     Yii2::assertType($provider, ActiveDataProvider::class);
     $query = $provider->query;
     Yii2::assertType($query, ActiveQuery::class);
     $this->provider = $provider;
     $this->query = $query;
 }
開發者ID:nanodesu88,項目名稱:yii2-activerecord-sort,代碼行數:17,代碼來源:SortColumn.php

示例15: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $view = $this->grid->getView();
     $script = '
     $(document).ready(function(){
         function hideFirstLast() {
             $(\'.sort-up, .sort-down\').show();
             $(\'.sort-up\').first().hide();
             $(\'.sort-down\').last().hide();
         }
         $(\'.sort-up\').on(\'click\', function(){
             var element = $(this).parent().parent();
             var id1 = element.attr(\'data-key\');
             var id2 = element.prev().attr(\'data-key\');
             element.prev().before(element);
             hideFirstLast();
             $.ajax({
                 url: "' . Url::toRoute(['swap']) . '?idFrom="+id1+"&idTo="+id2
             });
             return false;
         });
         $(\'.sort-down\').on(\'click\' ,function(){
             var element = $(this).parent().parent();
             var id1 = element.attr(\'data-key\');
             var id2 = element.next().attr(\'data-key\');
             element.next().after(element);
             hideFirstLast();
             $.ajax({
                 url: "' . Url::toRoute(['swap']) . '?idFrom="+id1+"&idTo="+id2
             });
             return false;
         });
         hideFirstLast();
     });';
     $view->registerJs($script);
 }
開發者ID:greshnik,項目名稱:yii2-grid-sort-column,代碼行數:40,代碼來源:SortColumn.php


注:本文中的yii\grid\Column類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。