当前位置: 首页>>代码示例>>PHP>>正文


PHP grid\DataColumn类代码示例

本文整理汇总了PHP中yii\grid\DataColumn的典型用法代码示例。如果您正苦于以下问题:PHP DataColumn类的具体用法?PHP DataColumn怎么用?PHP DataColumn使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DataColumn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actions

 /**
  * @inheritdoc
  */
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['index' => ['columns' => [['attribute' => 'status', 'class' => \yii\grid\DataColumn::className(), 'filter' => \skeeks\cms\comments2\models\Comments2Message::$statuses, 'format' => 'raw', 'value' => function (\skeeks\cms\comments2\models\Comments2Message $model) {
         if ($model->status == \skeeks\cms\comments2\models\Comments2Message::STATUS_NEW) {
             $class = "default";
         } else {
             if ($model->status == \skeeks\cms\comments2\models\Comments2Message::STATUS_PROCESSED) {
                 $class = "warning";
             } else {
                 if ($model->status == \skeeks\cms\comments2\models\Comments2Message::STATUS_CANCELED) {
                     $class = "danger";
                 } else {
                     if ($model->status == \skeeks\cms\comments2\models\Comments2Message::STATUS_ALLOWED) {
                         $class = "success";
                     }
                 }
             }
         }
         return '<span class="label label-' . $class . '">' . \yii\helpers\ArrayHelper::getValue(\skeeks\cms\comments2\models\Comments2Message::$statuses, $model->status) . '</span>';
     }], ['class' => \skeeks\cms\grid\CreatedAtColumn::className(), 'label' => 'Добавлен'], ['class' => \skeeks\cms\grid\CreatedByColumn::className()], ['attribute' => 'site_code', 'class' => \yii\grid\DataColumn::className(), 'filter' => \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->all(), 'code', 'name'), 'value' => function (\skeeks\cms\comments2\models\Comments2Message $model) {
         return $model->site->name;
     }], ['attribute' => 'element_id', 'relation' => 'element', 'class' => \skeeks\cms\grid\CmsContentElementColumn::className()], ['filter' => \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsContent::find()->all(), 'id', 'name'), 'attribute' => 'content_id', 'class' => \yii\grid\DataColumn::className(), 'value' => function (\skeeks\cms\comments2\models\Comments2Message $model) {
         return $model->element->cmsContent->name;
     }]]], "status-allowed-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => \skeeks\cms\comments2\Module::t('app', 'Approve'), "eachCallback" => [$this, 'eachMultiStatusAllowed']], "status-canceled-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => \skeeks\cms\comments2\Module::t('app', 'Reject'), "eachCallback" => [$this, 'eachMultiStatusCanceled']], "status-processed-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => \skeeks\cms\comments2\Module::t('app', 'In progress'), "eachCallback" => [$this, 'eachMultiStatusProcessed']]]);
 }
开发者ID:skeeks-cms,项目名称:cms-module-comments,代码行数:28,代码来源:AdminMessageController.php

示例2: init

 public function init()
 {
     parent::init();
     $this->content = function (ModelBase $model, $key, $index, DataColumn $column) {
         return Html::a($model->{$column->attribute}, ['view', 'id' => $model->primaryKey], ['title' => Yii::t('common', 'View')]);
     };
 }
开发者ID:dersonsena,项目名称:yii2-common-classes,代码行数:7,代码来源:LinkDataColumn.php

示例3: actions

    /**
     * @inheritdoc
     */
    public function actions()
    {
        return ArrayHelper::merge(parent::actions(), ['index' => ["columns" => [['class' => CreatedAtColumn::className()], 'id', ['class' => DataColumn::className(), 'attribute' => 'status_code', 'format' => 'raw', 'filter' => ArrayHelper::map(ShopOrderStatus::find()->all(), 'code', 'name'), 'value' => function (ShopOrder $order) {
            return Html::label($order->status->name, null, ['style' => "background: {$order->status->color}", 'class' => "label"]) . "<br />" . Html::tag("small", \Yii::$app->formatter->asDatetime($order->status_at) . " (" . \Yii::$app->formatter->asRelativeTime($order->status_at) . ")");
        }], ['class' => BooleanColumn::className(), 'attribute' => 'payed', 'format' => 'raw'], ['class' => DataColumn::className(), 'attribute' => "canceled", 'format' => "raw", 'filter' => ['Y' => \Yii::t('app', 'Yes'), 'N' => \Yii::t('app', 'No')], 'value' => function (ShopOrder $shopOrder) {
            return $shopOrder->canceled == "Y" ? \Yii::t('app', 'Yes') : \Yii::t('app', 'No');
        }], ['class' => DataColumn::className(), 'attribute' => "user_id", 'label' => \skeeks\cms\shop\Module::t('app', 'Buyer'), 'format' => "raw", 'value' => function (ShopOrder $shopOrder) {
            return (new \skeeks\cms\shop\widgets\AdminBuyerUserWidget(['user' => $shopOrder->user]))->run();
        }], ['class' => DataColumn::className(), 'filter' => false, 'format' => 'raw', 'label' => \skeeks\cms\shop\Module::t('app', 'Good'), 'value' => function (ShopOrder $model) {
            if ($model->shopBaskets) {
                $result = [];
                foreach ($model->shopBaskets as $shopBasket) {
                    $money = \Yii::$app->money->intlFormatter()->format($shopBasket->money);
                    $result[] = Html::a($shopBasket->name, $shopBasket->product->cmsContentElement->url, ['target' => '_blank']) . <<<HTML
  — {$shopBasket->quantity} {$shopBasket->measure_name}
HTML;
                }
                return implode('<hr style="margin: 0px;"/>', $result);
            }
        }], ['class' => DataColumn::className(), 'format' => 'raw', 'attribute' => 'price', 'label' => \skeeks\cms\shop\Module::t('app', 'Sum'), 'value' => function (ShopOrder $model) {
            return \Yii::$app->money->intlFormatter()->format($model->money);
        }], ['class' => DataColumn::className(), 'filter' => ArrayHelper::map(CmsSite::find()->active()->all(), 'id', 'name'), 'attribute' => 'site_id', 'format' => 'raw', 'visible' => false, 'label' => \skeeks\cms\shop\Module::t('app', 'Site'), 'value' => function (ShopOrder $model) {
            return $model->site->name . " [{$model->site->code}]";
        }]]], "view" => ['class' => AdminOneModelEditAction::className(), "name" => \Yii::t('app', "Информация"), "icon" => "glyphicon glyphicon-eye-open", "priority" => 5, "callback" => [$this, 'view']]]);
    }
开发者ID:3737002,项目名称:cms-shop,代码行数:28,代码来源:AdminOrderController.php

示例4: createDataColumn

 /**
  * @see \yii\grid\GridView::createDataColumn()
  * @inheritdoc
  */
 protected function createDataColumn($text)
 {
     if (!preg_match('/^([^:]+)(:(\\w*))?(:(.*))?$/', $text, $matches)) {
         throw new InvalidConfigException('The column must be specified in the format of "attribute", "attribute:format" or "attribute:format:label"');
     }
     return Yii::createObject(['class' => $this->dataColumnClass ?: DataColumn::className(), 'grid' => $this, 'attribute' => $matches[1], 'format' => isset($matches[3]) ? $matches[3] : 'text', 'label' => isset($matches[5]) ? $matches[5] : null]);
 }
开发者ID:ericmaicon,项目名称:yii2-export,代码行数:11,代码来源:GridViewTrait.php

示例5: actions

 /**
  * @inheritdoc
  */
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['index' => ["gridConfig" => ['settingsData' => ['order' => SORT_ASC, 'orderBy' => "priority"]], "columns" => ['name', 'priority', ['class' => DataColumn::className(), 'attribute' => "shopPaySystems", 'filter' => false, 'value' => function (ShopDelivery $model) {
         return implode(", ", ArrayHelper::map($model->shopPaySystems, 'id', 'name'));
     }], ['class' => DataColumn::className(), 'attribute' => "price", 'format' => 'raw', 'filter' => false, 'value' => function (ShopDelivery $model) {
         return \Yii::$app->money->intlFormatter()->format($model->money);
     }], ['class' => BooleanColumn::className(), 'attribute' => "active"]]]]);
 }
开发者ID:BMOTech,项目名称:cms-shop,代码行数:11,代码来源:AdminDeliveryController.php

示例6: actions

 /**
  * @inheritdoc
  */
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['index' => ["columns" => ['value', ['class' => DataColumn::className(), 'value' => function (ShopTaxRate $model) {
         return $model->tax->name . " (" . $model->tax->site->name . ")";
     }, 'attribute' => "tax_id"], ['class' => DataColumn::className(), 'value' => function (ShopTaxRate $model) {
         return $model->personType->name;
     }, 'attribute' => "person_type_id"], ['class' => BooleanColumn::className(), 'attribute' => "is_in_price"], ['class' => BooleanColumn::className(), 'attribute' => "active"], ['attribute' => "priority"]]]]);
 }
开发者ID:BMOTech,项目名称:cms-shop,代码行数:11,代码来源:AdminTaxRateController.php

示例7: init

 public function init()
 {
     $this->headerOptions = ['class' => 'text-center', 'style' => 'width: 115px'];
     $this->contentOptions = ['class' => 'text-center'];
     parent::init();
     $this->content = function (ModelBase $model, $key, $index, DataColumn $column) {
         return ControllerBase::getYesNoLabel($model->{$column->attribute});
     };
 }
开发者ID:dersonsena,项目名称:yii2-common-classes,代码行数:9,代码来源:YesNoDataColumn.php

示例8: init

 public function init()
 {
     parent::init();
     if (!$this->filter) {
         $this->filter = \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->all(), 'code', 'name');
     }
 }
开发者ID:Liv1020,项目名称:cms,代码行数:7,代码来源:SiteColumn.php

示例9: init

 public function init()
 {
     parent::init();
     if (!isset($this->headerOptions['width'])) {
         $this->headerOptions['width'] = $this->width;
     }
 }
开发者ID:phpsong,项目名称:lulucms2,代码行数:7,代码来源:DataColumn.php

示例10: init

 public function init()
 {
     parent::init();
     if (!isset($this->headerOptions['width'])) {
         $this->headerOptions['width'] = $this->width;
     }
     $this->contentOptions = ['style' => 'word-wrap: break-word; word-break: break-all;'];
 }
开发者ID:sym660,项目名称:lulucms2,代码行数:8,代码来源:DataColumn.php

示例11: renderDataCellContent

 protected function renderDataCellContent($model, $key, $index)
 {
     if ($this->editable === true) {
         return Html::tag('a', parent::renderDataCellContent($model, $key, $index), ['class' => 'editable']);
     } else {
         return parent::renderDataCellContent($model, $key, $index);
     }
 }
开发者ID:NikDevPHP,项目名称:yii2,代码行数:8,代码来源:EditableTreeGridDataColumn.php

示例12: init

 /**
  * Init
  */
 public function init()
 {
     parent::init();
     $this->setDefaultOptions();
     $this->setCellStyleOptions();
     $this->initOptions();
     $this->grid->view->registerJs($this->sortButtonJs());
 }
开发者ID:gpis88ce,项目名称:Gpis88ce,代码行数:11,代码来源:SorterColumn.php

示例13: renderDataCellContent

 protected function renderDataCellContent($model, $key, $index)
 {
     if ($this->content === null) {
         return $this->getDataCellValue($model, $key, $index);
     } else {
         return parent::renderDataCellContent($model, $key, $index);
     }
 }
开发者ID:andreosoft,项目名称:andreocms,代码行数:8,代码来源:ImageColumn.php

示例14: init

 public function init()
 {
     parent::init();
     $model = $this->grid->filterModel;
     if ($model) {
         $this->filter = $model->getPossibleStatuses();
     }
 }
开发者ID:Liv1020,项目名称:cms,代码行数:8,代码来源:StatusColumn.php

示例15: renderDataCellContent

 /**
  * @inheritdoc
  */
 protected function renderDataCellContent($model, $key, $index)
 {
     if ($this->content === null) {
         return Html::a('<span class="glyphicon glyphicon-arrow-up"></span>', $this->getUrl('up', $model), ['class' => 'order-link']) . Html::a('<span class="glyphicon glyphicon-arrow-down"></span>', $this->getUrl('down', $model), ['class' => 'order-link']);
     } else {
         return parent::renderDataCellContent($model, $key, $index);
     }
 }
开发者ID:Wubbleyou,项目名称:yii2-ordermodel,代码行数:11,代码来源:OrderModelColumn.php


注:本文中的yii\grid\DataColumn类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。