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


PHP GridView::widget方法代码示例

本文整理汇总了PHP中yii\grid\GridView::widget方法的典型用法代码示例。如果您正苦于以下问题:PHP GridView::widget方法的具体用法?PHP GridView::widget怎么用?PHP GridView::widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\grid\GridView的用法示例。


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

示例1: run

 /**
  * @inheritdoc
  * @return bool|string
  * @throws Exception
  */
 public function run()
 {
     $model = $this->model;
     if (!$model) {
         return false;
     }
     if (!$model->hasMethod('getLog')) {
         throw new Exception("Attach " . ChangeLogBehavior::className() . " behavior to " . $model::className());
     }
     /**
      * @var ChangeLogBehavior $model
      */
     $logProvider = $model->getLog();
     $view = $this->header;
     $view .= GridView::widget(['dataProvider' => $logProvider, 'columns' => ['log_time:datetime', 'prefix', ['attribute' => 'message', 'content' => function ($item) {
         $messages = unserialize($item['message']);
         if (is_array($messages)) {
             $message = "";
             foreach ($messages as $attr => $changes) {
                 $message .= $attr . ": " . $changes . "<br>";
             }
             return $message;
         }
         return $messages;
     }]]]);
     return $view;
 }
开发者ID:cranky4,项目名称:change-log-behavior,代码行数:32,代码来源:ChangeLogList.php

示例2: run

 public function run()
 {
     if (!$this->model) {
         return Html::tag('div', Html::tag('b', Yii::t('yii', 'Error')) . ': ' . $this->getModule()->t('attachments', 'The model cannot be empty.'), ['class' => 'alert alert-danger']);
     }
     $hasFileBehavior = false;
     foreach ($this->model->getBehaviors() as $behavior) {
         if (is_a($behavior, FileBehavior::className())) {
             $hasFileBehavior = true;
         }
     }
     if (!$hasFileBehavior) {
         return Html::tag('div', Html::tag('b', Yii::t('yii', 'Error')) . ': ' . $this->getModule()->t('attachments', 'The behavior FileBehavior has not been attached to the model.'), ['class' => 'alert alert-danger']);
     }
     Url::remember(Url::current());
     return GridView::widget(['dataProvider' => new ArrayDataProvider(['allModels' => $this->model->getFiles()]), 'layout' => '{items}', 'tableOptions' => $this->tableOptions, 'columns' => [['label' => $this->getModule()->t('attachments', 'File name'), 'format' => 'raw', 'value' => function (File $model) {
         return Html::a("{$model->name}.{$model->type}", $model->getUrl());
     }], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model, $key) {
         return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['/file/file/delete', 'id' => $model->id], ['title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post']);
     }]]]]);
 }
开发者ID:axelpal,项目名称:yii2-attachments,代码行数:21,代码来源:AttachmentsTable.php

示例3: run

    public function run()
    {
        $confirm = Yii::t('yii', 'Are you sure you want to delete this item?');
        $js = <<<JS
        \$(".delete-button").click(function(){
            var tr = this.closest('tr');
            var url = \$(this).data('url');
            if (confirm("{$confirm}")) {
                \$.ajax({
                    method: "POST",
                    url: url,
                    success: function(data) {
                        if (data) {
                            tr.remove();
                        }
                    }
                });
            }
        });
JS;
        Yii::$app->view->registerJs($js);
        return GridView::widget(['dataProvider' => new ArrayDataProvider(['allModels' => $this->model->getFiles()]), 'layout' => '{items}', 'tableOptions' => $this->tableOptions, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['label' => $this->getModule()->t('attachments', 'File name'), 'format' => 'raw', 'value' => function ($model) {
            return Html::a("{$model->name}.{$model->type}", $model->getUrl());
        }], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model, $key) {
            return Html::a('<span class="glyphicon glyphicon-trash"></span>', '#', ['class' => 'delete-button', 'title' => Yii::t('yii', 'Delete'), 'data-url' => Url::to(['/attachments/file/delete', 'id' => $model->id])]);
        }]]]]);
    }
开发者ID:nemmo,项目名称:yii2-attachments,代码行数:27,代码来源:AttachmentsTable.php

示例4: renderViews

 /**
  * Renders interpreter tabs
  * @return string tabs
  */
 protected function renderViews()
 {
     $columns = ArrayHelper::getColumn($this->_relViews, function ($element) {
         return sprintf('%s:raw', $element['label']);
     });
     if ($this->actions) {
         array_push($columns, $this->actions);
     }
     $provider = new \yii\data\ArrayDataProvider(['allModels' => [ArrayHelper::map($this->_relViews, 'label', 'content')]]);
     echo \yii\grid\GridView::widget(['dataProvider' => $provider, 'columns' => $columns, 'layout' => '{items}', 'pager' => false]);
 }
开发者ID:dlds,项目名称:yii2-rels,代码行数:15,代码来源:RelGrid.php

示例5: getTable

 protected function getTable()
 {
     $options = ['dataProvider' => $this->dataProvider, 'summary' => '', 'tableOptions' => $this->tableOptions];
     if ($this->columns) {
         $options['columns'] = $this->columns;
     }
     $table = $this->getPjaxBegin();
     $table .= GridView::widget($options);
     $table .= $this->getPjaxEnd();
     return $table;
 }
开发者ID:lukianovva,项目名称:clover,代码行数:11,代码来源:Table.php

示例6: CreateGridWithDropDownListHeader

 public static function CreateGridWithDropDownListHeader($dataProvider, $form, $header_model, $arr_header_values)
 {
     $columns_config = [['class' => SerialColumn::className()]];
     $i = 0;
     foreach ($header_model as $key => $value) {
         $columns_config[] = ['header' => $form->field($header_model, $key, ['inputOptions' => ['label' => '']])->dropDownList($arr_header_values), 'attribute' => $i];
         $i++;
     }
     $dynamic_grid_view = GridView::widget(['dataProvider' => $dataProvider, 'columns' => $columns_config]);
     return $dynamic_grid_view;
 }
开发者ID:heartshare,项目名称:yii-multiparser,代码行数:11,代码来源:DynamicFormHelper.php

示例7: run

 public function run()
 {
     switch ($this->identity->hasApiTokens()) {
         case true:
             $dataProvider = new \yii\data\ArrayDataProvider(['allModels' => $this->identity->getApiTokens()]);
             echo \yii\grid\GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['id', 'token:ntext', 'added', 'active:boolean', 'level', 'revoked:boolean', 'revoked_on'], 'rowOptions' => function ($model, $key, $index, $grid) {
                 return ["class" => \Yii::$app->controller->getStatusIndicator($this->identity)];
             }, "tableOptions" => ['class' => 'table table-bordered']]);
             break;
         default:
             echo Html::tag('div', "No tokens found");
             break;
     }
 }
开发者ID:nhatvuvan,项目名称:yii2-widgets,代码行数:14,代码来源:Tokens.php

示例8: run

 public function run()
 {
     $dataProvider = new \yii\data\ArrayDataProvider(["allModels" => is_array($this->items) && !empty($this->items) ? $this->items : $this->model->getModels(), 'pagination' => false]);
     switch (\Yii::$app->user->identity->isAdmin()) {
         case true:
             break;
     }
     $revisions = GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['attribute' => 'author_id', 'label' => 'Author', 'format' => 'html', 'value' => function ($model, $index, $widget) {
         return $model->author()->url();
     }], 'created_at', ['attribute' => 'parent_type', 'label' => 'Type'], ['class' => 'yii\\grid\\ActionColumn', 'buttons' => $this->getActions(), 'template' => "{view} {restore} {delete}", 'urlCreator' => function ($action, $model, $key, $index) {
         return \Yii::$app->controller->id . '/' . $action . '/' . $model->getId();
     }, 'options' => ['rowspan' => 3]]], 'rowOptions' => function ($model, $key, $index, $grid) {
         return ["class" => \nitm\helpers\Statuses::getIndicator($model->getStatus())];
     }, "tableOptions" => ['class' => 'table']]);
     $this->options['id'] .= $this->parentId;
     echo Html::tag('div', $revisions, $this->options);
 }
开发者ID:nhatvuvan,项目名称:yii2-widgets,代码行数:17,代码来源:Revisions.php

示例9: run

 public function run()
 {
     if (!$this->model) {
         return Html::tag('div', Html::tag('b', Yii::t('yii', 'Error')) . ': ' . $this->getModule()->t('attachments', 'The model cannot be empty.'), ['class' => 'alert alert-danger']);
     }
     $hasFileBehavior = false;
     foreach ($this->model->getBehaviors() as $behavior) {
         if ($behavior->className() == FileBehavior::className()) {
             $hasFileBehavior = true;
         }
     }
     if (!$hasFileBehavior) {
         return Html::tag('div', Html::tag('b', Yii::t('yii', 'Error')) . ': ' . $this->getModule()->t('attachments', 'The behavior FileBehavior has not been attached to the model.'), ['class' => 'alert alert-danger']);
     }
     Url::remember(Url::current());
     return GridView::widget(['dataProvider' => new ArrayDataProvider(['allModels' => $this->model->getFiles()]), 'layout' => '{items}', 'tableOptions' => $this->tableOptions, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['label' => $this->getModule()->t('attachments', 'File name'), 'format' => 'raw', 'value' => function ($model) {
         return Html::a("{$model->name}.{$model->type}", $model->getUrl(), ['class' => ' group' . $model->itemId, 'onclick' => 'return false;']);
     }], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model, $key) {
         return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['/attachments/file/delete', 'id' => $model->id], ['title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post']);
     }]]]]) . Colorbox::widget(['targets' => ['.group' . $this->model->id => ['rel' => '.group' . $this->model->id, 'photo' => true, 'scalePhotos' => true, 'width' => '100%', 'height' => '100%', 'maxWidth' => 800, 'maxHeight' => 600]], 'coreStyle' => 4]);
 }
开发者ID:zhaoyan158567,项目名称:yii2-attachments,代码行数:21,代码来源:AttachmentsTableWithPreview.php

示例10: run

    public function run()
    {
        if (!$this->model) {
            return Html::tag('div', Html::tag('b', Yii::t('yii', 'Error')) . ': ' . $this->getModule()->t('attachments', 'The model cannot be empty.'), ['class' => 'alert alert-danger']);
        }
        $hasFileBehavior = false;
        foreach ($this->model->getBehaviors() as $behavior) {
            if ($behavior instanceof FileBehavior) {
                $hasFileBehavior = true;
                break;
            }
        }
        if (!$hasFileBehavior) {
            return Html::tag('div', Html::tag('b', Yii::t('yii', 'Error')) . ': ' . $this->getModule()->t('attachments', 'The behavior FileBehavior has not been attached to the model.'), ['class' => 'alert alert-danger']);
        }
        $confirm = Yii::t('yii', 'Are you sure you want to delete this item?');
        $js = <<<JS
        \$(".delete-button").click(function(){
            var tr = this.closest('tr');
            var url = \$(this).data('url');
            if (confirm("{$confirm}")) {
                \$.ajax({
                    method: "POST",
                    url: url,
                    success: function(data) {
                        if (data) {
                            tr.remove();
                        }
                    }
                });
            }
        });
JS;
        Yii::$app->view->registerJs($js);
        return GridView::widget(['dataProvider' => new ArrayDataProvider(['allModels' => $this->model->getFiles()]), 'layout' => '{items}', 'tableOptions' => $this->tableOptions, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['label' => $this->getModule()->t('attachments', 'File name'), 'format' => 'raw', 'value' => function ($model) {
            return Html::a("{$model->name}.{$model->type}", $model->getUrl(), ['class' => ' group' . $model->itemId, 'onclick' => 'return false;']);
        }], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model, $key) {
            return Html::a('<span class="glyphicon glyphicon-trash"></span>', '#', ['class' => 'delete-button', 'title' => Yii::t('yii', 'Delete'), 'data-url' => Url::to(['/attachments/file/delete', 'id' => $model->id])]);
        }]]]]) . Colorbox::widget(['targets' => ['.group' . $this->model->id => ['rel' => '.group' . $this->model->id, 'photo' => true, 'scalePhotos' => true, 'width' => '100%', 'height' => '100%', 'maxWidth' => 800, 'maxHeight' => 600]], 'coreStyle' => 4]);
    }
开发者ID:nemmo,项目名称:yii2-attachments,代码行数:40,代码来源:AttachmentsTableWithPreview.php

示例11: function

<?php

use yii\helpers\Html;
use yii\grid\GridView;
?>
<div class="bank-master-index">
    <?php 
$org = app\models\Organization::find()->asArray()->one();
$model->sort = false;
$dispColumn = false;
if ($type == 'Excel') {
    $dispColumn = true;
    echo "<meta http-equiv=\"Content-type\" content=\"text/html;charset=utf-8\" />";
    echo "<table><tr> <th colspan='7'><h3>" . $org['org_name'] . "</h3> </th> </tr> </table>";
}
?>
    <?php 
echo GridView::widget(['dataProvider' => $model, 'layout' => '{items}', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'bank_master_name', 'bank_alias', ['attribute' => 'created_at', 'value' => function ($data) {
    return Yii::$app->formatter->asDateTime($data->created_at);
}, 'visible' => $dispColumn], ['attribute' => 'created_by', 'value' => 'createdBy.user_login_id', 'visible' => $dispColumn], ['attribute' => 'updated_at', 'value' => function ($data) {
    return !empty($data->updated_at) ? Yii::$app->formatter->asDateTime($data->updated_at) : " (not set) ";
}, 'visible' => $dispColumn], ['attribute' => 'updated_by', 'value' => 'updatedBy.user_login_id', 'visible' => $dispColumn]]]);
?>

</div>
开发者ID:anazhd,项目名称:EduSec,代码行数:25,代码来源:BankMasterExportPdfExcel.php

示例12: ActiveDataProvider

<div class="box-header with-border">
	<h3 class="box-title"><i class="fa fa-inr"></i><sup><i class="fa fa-clock-o"></i></sup> <?php 
echo Yii::t('fees', 'Payment History');
?>
</h3>
</div>
<div class="box-body table-responsive no-padding">
<?php 
$stuFeesData = app\modules\fees\models\FeesPaymentTransaction::find()->where(['fees_pay_tran_stu_id' => $stuData->stu_master_id, 'fees_pay_tran_collect_id' => $FccModel->fees_collect_category_id, 'is_status' => 0]);
$dataProvider = new ActiveDataProvider(['query' => $stuFeesData, 'sort' => ['defaultOrder' => ['fees_pay_tran_id' => SORT_DESC]], 'pagination' => ['pageSize' => 10]]);
\yii\widgets\Pjax::begin(['enablePushState' => FALSE]);
echo GridView::widget(['dataProvider' => $dataProvider, 'layout' => "{items}\n{pager}", 'showOnEmpty' => true, 'emptyText' => Yii::t('fees', 'No fees results found.'), 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'fees_pay_tran_id', ['attribute' => 'fees_pay_tran_date', 'value' => function ($data) {
    return Yii::$app->dateformatter->getDateDisplay($data['fees_pay_tran_date']);
}], ['attribute' => 'fees_pay_tran_mode', 'value' => function ($data) {
    return $data->fees_pay_tran_mode == 1 ? "Cash" : "Cheque";
}], ['attribute' => 'fees_pay_tran_cheque_no', 'value' => function ($data) {
    return !empty($data->fees_pay_tran_cheque_no) ? $data->fees_pay_tran_cheque_no : "-";
}], ['attribute' => 'fees_pay_tran_bank_id', 'value' => function ($data) {
    return !empty($data->feesPayTranBank->bank_master_name) ? $data->feesPayTranBank->bank_master_name : "-";
}], 'fees_pay_tran_bank_branch', 'fees_pay_tran_amount', ['class' => 'app\\components\\CustomActionColumn', 'template' => '{update} {delete}']]]);
\yii\widgets\Pjax::end();
?>
</div><!---End Pannel Body Of Student Payment History--->
</div><!---End Payment History box Block--->

<!--/div--> <!--------End responcive div tag------>

<!--/div-->
</div>
<script>
$(document).ready(function(){
开发者ID:EduSec,项目名称:EduSec,代码行数:31,代码来源:_form.php

示例13:

?>
<div class="venda-index">

    <!-- <h1><?= Html::encode($this->title) ?></h1> -->
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', 'Create Venda'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'idvenda',
            'data',
            'desconto',
            'valortotal',
            'cliente_idcliente',
            // 'vendedor_idvendedor',
            'forma_pagamento_idforma_pagamento',
            // 'loja_idloja',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>

</div>
开发者ID:alissoncti,项目名称:sgo,代码行数:30,代码来源:index.php

示例14:

<?php

use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\KeyStorageItemSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend', 'Key Storage Items');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="key-storage-item-index">

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

    <p>
        <?php 
echo Html::a(Yii::t('backend', 'Create {modelClass}', ['modelClass' => 'Key Storage Item']), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'key', 'value', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
?>

</div>
开发者ID:rafalsky,项目名称:home-finance,代码行数:27,代码来源:index.php

示例15: array

<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\grid\ActionColumn;
/**
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var app\modules\user\models\SearchUser $searchModel
 */
$this->title = 'Список страниц';
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="">
   <?php 
echo GridView::widget(['id' => 'pages-grid', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'options' => array('width' => '50px')], ['attribute' => 'title', 'format' => 'html', 'value' => function ($model) {
    return Html::a($model['title'], ['update', 'id' => $model['id']]);
}], ['attribute' => 'alias', 'format' => 'url', 'value' => function ($model) {
    return \yii\helpers\Url::To('@web/page/' . $model->alias, true);
}], ['attribute' => 'created_at', 'format' => ['date', 'dd.MM.yyyy'], 'options' => array('width' => '225px'), 'filter' => \yii\jui\DatePicker::widget(['dateFormat' => 'dd.MM.yyyy', 'model' => $searchModel, 'attribute' => 'created_at', 'options' => ['class' => 'form-control'], 'clientOptions' => ['dateFormat' => 'dd.mm.yy']])], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>

开发者ID:akula22,项目名称:fifa,代码行数:23,代码来源:index.php


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