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


PHP grid\GridView类代码示例

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


在下文中一共展示了GridView类的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: init

 /**
  * Inits widget
  */
 public function init()
 {
     parent::init();
     $this->initVisible();
     $this->initSortable();
     //GridViewAsset::register($this->view);
 }
开发者ID:diginova,项目名称:yii2-metronic,代码行数:10,代码来源:GridView.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: run

    public function run(){

        if($this->is_pjax){
            Pjax::begin($this->pjaxOptions);
        }

        parent::run();

        if($this->isShowForm) {
            echo PageSize::widget([
                'model'     => $this->filterModel,
                'attribute' => $this->attribute,
                'options'   => [
                    'data-pjax' => '0',
                ],
            ]);
        }

        if($this->is_pjax){
            Pjax::end();
        }

        echo ModelCrud::widget([
            'size' => $this->modalSize,
            'updateUrl' => ($this->updateUrl)? $this->updateUrl : Url::to(['update']),
            'createUrl' => ($this->createUrl)? $this->createUrl : Url::to(['create']),
            'updateVerb' => 'post',
            'viewUrl' => Url::to(['view']),
            'viewVerb' => 'post',
            'createVerb' => 'post',
            'modelTitle' => $this->modelTitle,
            'template' => '{view}{update}{create}',
            'modelClass' =>  $this->dataProvider->query->modelClass
        ]);
    }
开发者ID:harish-reglobbe,项目名称:Auction,代码行数:35,代码来源:GridView.php

示例5: init

 public function init()
 {
     parent::init();
     $this->emptyText = Html::t('templete', 'noData');
     $this->summary = Html::t('templete', 'summary');
     $this->getView()->registerCssFile('/css/listStyle.css');
 }
开发者ID:fufudao,项目名称:yii2-base,代码行数:7,代码来源:GridView.php

示例6: renderPager

 public function renderPager()
 {
     // /controller/action -> #!controller/action
     $str = parent::renderPager();
     $str = str_replace('href="/', 'href="#!', $str);
     return $str;
 }
开发者ID:nisnaker,项目名称:yii2-template,代码行数:7,代码来源:GridView.php

示例7: init

 public function init()
 {
     $this->showHeader = false;
     $this->showFooter = false;
     $this->layout = '{items}';
     $this->columns = [['class' => 'yii\\grid\\DataColumn', 'format' => 'raw', 'value' => function ($post) {
         foreach ($post->postDates as $postDate) {
             if (!isset($first)) {
                 $first = $postDate->PostDate;
             }
             $last = $postDate->PostDate;
         }
         if ($first == $last) {
             $value = $first;
         } else {
             $value = $first . ' &mdash; ' . $last;
         }
         if ($post->PostText) {
             $value = $value . '<br />' . $post->PostText;
         }
         return $value;
     }], ['format' => 'raw', 'value' => function ($post) {
         return '<span class="js-past_vacation_delete grid_delete_icon" data-post-id="' . $post->PostID . '"><i class="fa fa-trash"></i></span>';
     }]];
     parent::init();
 }
开发者ID:vladimirgolovanov,项目名称:purrfect-awesome-friends-feed-decorator,代码行数:26,代码来源:PastDatesGrid.php

示例8: renderTableBody

 /**
  * @inheritdoc
  * @return string the rendering result.
  */
 public function renderTableBody()
 {
     if (!$this->showHeader) {
         return parent::renderTableBody();
     }
     $models = array_values($this->dataProvider->getModels());
     $keys = $this->dataProvider->getKeys();
     $rows = [];
     foreach ($models as $index => $model) {
         $key = $keys[$index];
         if ($this->beforeRow !== null) {
             $row = call_user_func($this->beforeRow, $model, $key, $index, $this);
             if (!empty($row)) {
                 $rows[] = $row;
             }
         }
         $rows[] = $this->renderTableRow($model, $key, $index);
         if ($this->afterRow !== null) {
             $row = call_user_func($this->afterRow, $model, $key, $index, $this);
             if (!empty($row)) {
                 $rows[] = $row;
             }
         }
     }
     if (empty($rows)) {
         $colspan = count($this->columns);
         return "\n<tr><td colspan=\"{$colspan}\">" . $this->renderEmpty() . "</td></tr>\n</tbody>";
     } else {
         return "\n" . implode("\n", $rows) . "\n</tbody>";
     }
 }
开发者ID:h11Nox,项目名称:slug,代码行数:35,代码来源:GridView.php

示例9: renderTableRow

 public function renderTableRow($model, $key, $index)
 {
     if ($this->filterRow !== null && call_user_func($this->filterRow, $model, $key, $index, $this) === false) {
         return '';
     }
     return parent::renderTableRow($model, $key, $index);
 }
开发者ID:hucongyang,项目名称:lulucms2,代码行数:7,代码来源:GridView.php

示例10: renderSection

 public function renderSection($name)
 {
     if ($name == '{tools}') {
         return $this->renderTools();
     } else {
         return parent::renderSection($name);
     }
 }
开发者ID:vinhhx,项目名称:yii2_basic_startup,代码行数:8,代码来源:GridView.php

示例11: renderSection

 /**
  * @inheritdoc
  */
 public function renderSection($name)
 {
     if (isset($this->pluginSections[$name])) {
         return $this->pluginSections[$name]->run();
     } else {
         return parent::renderSection($name);
     }
 }
开发者ID:consultnn,项目名称:yii2-custom-grid,代码行数:11,代码来源:GridView.php

示例12: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     if (empty($this->columns)) {
         $this->columns = $this->columns();
     }
     $this->columns = array_merge($this->columns, $this->actions());
     parent::init();
 }
开发者ID:dawei101,项目名称:yii2-admin-module,代码行数:11,代码来源:Grid.php

示例13: run

 public function run()
 {
     parent::run();
     echo '</div>';
     if (!$this->options['ajax']) {
         $this->registerClientScripts();
         DataTablesAsset::register($this->getView());
     }
 }
开发者ID:andreosoft,项目名称:andreocms,代码行数:9,代码来源:GridViewEdited.php

示例14: renderSection

 /**
  * @inheritdoc
  */
 public function renderSection($name)
 {
     switch ($name) {
         case '{button}':
             return $this->button;
         default:
             return parent::renderSection($name);
     }
 }
开发者ID:hackvijay,项目名称:yii-qa,代码行数:12,代码来源:GridView.php

示例15: renderSection

 public function renderSection($name)
 {
     switch ($name) {
         case '{bulkActions}':
             return $this->renderBulkActions();
         default:
             return parent::renderSection($name);
     }
 }
开发者ID:yeesoft,项目名称:yii2-yee-core,代码行数:9,代码来源:GridView.php


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