本文整理汇总了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']]]);
}
示例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')]);
};
}
示例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']]]);
}
示例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]);
}
示例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"]]]]);
}
示例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"]]]]);
}
示例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});
};
}
示例8: init
public function init()
{
parent::init();
if (!$this->filter) {
$this->filter = \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->all(), 'code', 'name');
}
}
示例9: init
public function init()
{
parent::init();
if (!isset($this->headerOptions['width'])) {
$this->headerOptions['width'] = $this->width;
}
}
示例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;'];
}
示例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);
}
}
示例12: init
/**
* Init
*/
public function init()
{
parent::init();
$this->setDefaultOptions();
$this->setCellStyleOptions();
$this->initOptions();
$this->grid->view->registerJs($this->sortButtonJs());
}
示例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);
}
}
示例14: init
public function init()
{
parent::init();
$model = $this->grid->filterModel;
if ($model) {
$this->filter = $model->getPossibleStatuses();
}
}
示例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);
}
}