作者:skeeks-cm
项目:cms-module-comment
/**
* @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']]]);
}
作者:dersonsen
项目:yii2-common-classe
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')]);
};
}
作者:373700
项目:cms-sho
/**
* @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']]]);
}
作者:ericmaico
项目:yii2-expor
/**
* @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]);
}
作者:BMOTec
项目:cms-sho
/**
* @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"]]]]);
}
作者:BMOTec
项目:cms-sho
/**
* @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"]]]]);
}
作者:dersonsen
项目:yii2-common-classe
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});
};
}
作者:Liv102
项目:cm
public function init()
{
parent::init();
if (!$this->filter) {
$this->filter = \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->all(), 'code', 'name');
}
}
作者:phpson
项目:lulucms
public function init()
{
parent::init();
if (!isset($this->headerOptions['width'])) {
$this->headerOptions['width'] = $this->width;
}
}
作者:sym66
项目:lulucms
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;'];
}
作者:NikDevPH
项目:yii
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);
}
}
作者:gpis88c
项目:Gpis88c
/**
* Init
*/
public function init()
{
parent::init();
$this->setDefaultOptions();
$this->setCellStyleOptions();
$this->initOptions();
$this->grid->view->registerJs($this->sortButtonJs());
}
作者:andreosof
项目:andreocm
protected function renderDataCellContent($model, $key, $index)
{
if ($this->content === null) {
return $this->getDataCellValue($model, $key, $index);
} else {
return parent::renderDataCellContent($model, $key, $index);
}
}
作者:Liv102
项目:cm
public function init()
{
parent::init();
$model = $this->grid->filterModel;
if ($model) {
$this->filter = $model->getPossibleStatuses();
}
}
作者:Wubbleyo
项目:yii2-ordermode
/**
* @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);
}
}
作者:vvkgpt4
项目:merchium-advanced-ap
protected function renderDataCellContent($model, $key, $index)
{
$text = parent::renderDataCellContent($model, $key, $index);
if (in_array($this->format, ['text', 'date', 'datetime'])) {
return Html::a($text, null, $this->grid->prepareDetailsLink($model->id));
}
return $text;
}
作者:hiqde
项目:yii2-menumanage
/**
* @inheritdoc
*/
public function getDataCellValue($model, $key, $index)
{
if ($this->value !== null) {
return parent::getDataCellValue($model, $key, $index);
} else {
$class = $this->menuClass;
return $class::create(['model' => $model])->render(MenuButton::class);
}
}
作者:SimonBaeume
项目:humhu
/**
* @inheritdoc
*/
public function init()
{
if (!isset($this->ajaxOptions['type'])) {
$this->ajaxOptions['type'] = 'POST';
}
$this->ajaxOptions['data'] = new \yii\web\JsExpression('data');
$this->grid->view->registerJs("\$('.editableCell').change(function() {\n data = {};\n data[\$(this).attr('name')] = \$(this).val();\n submitAttributes = \$(this).data('submit-attributes').split(',');\n for (var i in submitAttributes) {\n data[submitAttributes[i]] = \$(this).data('attribute'+i);\n }\n data['dropDownColumnSubmit'] = true;\n \$.ajax(" . \yii\helpers\Json::encode($this->ajaxOptions) . ");\n });");
return parent::init();
}
作者:tqsq200
项目:dotplant
protected function renderDataCellContent($model, $key, $index)
{
$content = parent::renderDataCellContent($model, $key, $index);
if ($content == "1") {
return "<span class=\"label " . $this->true_label_class . "\">" . Yii::t('app', $this->true_value) . "</span>";
} else {
return "<span class=\"label " . $this->false_label_class . "\">" . Yii::t('app', $this->false_value) . "</span>";
}
}
作者:just-le
项目:cardgame-seria
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
$value = parent::renderDataCellContent($model, $key, $index);
if ($this->getDataCellValue($model, $key, $index) == true) {
return "<span class=\"label label-success\">{$value}</span>";
} else {
return "<span class=\"label label-default\">{$value}</span>";
}
}