Yii2 GridView添加摘要文本

问题描述 投票:0回答:2

我想在表摘要中添加summarytext如何实现这一点?

有搜索这个api,但仍然无法理解。

我的看法:

 <div>
    <div class="bg-primary text-white">i want to this in summary text</div>
    <?= GridView::widget([
        'dataProvider' => $provider,
        'summaryOptions' => [
            'class' => 'bg-primary text-white',
        ],
        'columns' => [
            'id',
            'address',
            'email',
            [
                'class' => 'yii\grid\ActionColumn',
                'header' => 'button',
                'headerOptions' => ['style' => 'color:#337ab7'],
                'template' => '{update}{delete}',
                'buttons' => [
                'update' => function ($url,$model) {
                    $url = Url::to(['controller/update', 'id' => $model->id]);
                    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
                                'title' => Yii::t('app', 'lead-update'),
                    ]);
                },
                'delete' => function ($url, $model) {
                    $url = Url::to(['controller/delete', 'id' => $model->id]);
                    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
                                'title' => Yii::t('app', 'lead-delete'),
                    ]);
                }
                ],
            ],
        ],
    ]);
    ?>
</div>

希望你的家伙可以帮助我谢谢!

gridview yii2
2个回答
0
投票

分配你需要的值和一个构建函数var来检索你需要的值你需要的var(或函数)的页脚,并在你的网格配置中设置showFooter = TRUE

<?php 
  $mySummary ="i want to this in summary text";

  echo  GridView::widget([
    'dataProvider' => $provider,
    'showFooter'=>TRUE,
    'summaryOptions' => [
        'class' => 'bg-primary text-white',
    ],
    'columns' => [
        'id',
        [
          'attribute' => 'address',
          'footer' => $mySummary,
        ]

        'email',
         .....

0
投票

我找到了我想要的东西

'caption'=>'<h2>Javed</h2>',
'captionOptions' => [
       'class' => 'bg-primary text-white',
],
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.