沃梦达 / 编程问答 / php问题 / 正文

Yii2:Kartik Gridview 页脚中一列的总和

Yii2: Kartik Gridview sum of a column in footer(Yii2:Kartik Gridview 页脚中一列的总和)

本文介绍了Yii2:Kartik Gridview 页脚中一列的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 Kartik gridview 扩展,它运行良好.

但是我在文档中找不到或遗漏了它,如何在页脚中显示一列的总和.

这是我在index.php

中的完整代码

'yiigridSerialColumn'],'ID',[//'attribute'='service_name','属性'='服务名称','value'=>'serviceName.services',],['attribute'='room_category','value'='roomCategory.room_category'],'charges_cash','charges_cashless',['类' =>'yiigridActionColumn']];echo ExportMenu::widget(['数据提供者' =>$数据提供者,'列' =>$gridColumns,'fontAwesome' =>真的,'showPageSummary' =>真的,'下拉选项' =>['标签' =>'全部导出','类' =>'btn btn-默认']])?></div></div><?= GridView::widget(['数据提供者' =>$数据提供者,'过滤器模型' =>$搜索模型,'列' =>[['类' =>'yiigridSerialColumn'],'ID',//'服务名称',[//'attribute'='service_name','属性'='服务名称','value'=>'serviceName.services',],//'房间类别',['attribute'='room_category','value'='roomCategory.room_category'],'charges_cash','charges_cashless',['类' =>'yiigridActionColumn'],],'showFooter' =>真的]);?>

正在寻找有关此问题的帮助.谢谢.

解决方案

我觉得你只需要添加页面摘要;

使用kartikgridGridView;//为您的 GridView 小部件创建面板布局回声 GridView::widget(['数据提供者'=>$数据提供者,'过滤器模型' =>$搜索模型,'列' =>$gridColumns,'showPageSummary' =>真的]);

Kartik 在演示和插件详细信息中对其进行了很好的描述.

I have installed the Kartik gridview extension, which is working fine.

But I couldn't find or missed it in the docs, how I can show the sum of a column in the footer.

This is my complete code in index.php

<?php 
        $gridColumns = [
    ['class' => 'yiigridSerialColumn'],
    'id',
    [
        //'attribute'=>'service_name',
        'attribute'=>'service_name',
        'value'=>'serviceName.services',                
    ],
    [
        'attribute'=>'room_category',
        'value'=>'roomCategory.room_category'
     ],
        'charges_cash',
        'charges_cashless',
    ['class' => 'yiigridActionColumn']
];

    echo ExportMenu::widget([
    'dataProvider' => $dataProvider,
    'columns' => $gridColumns,
    'fontAwesome' => true,
    'showPageSummary' => true,
    'dropdownOptions' => [
        'label' => 'Export All',
        'class' => 'btn btn-default'
    ]
]) 
        ?>
    </div></div>


    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yiigridSerialColumn'],

            'id',
            //'service_name',
            [
                //'attribute'=>'service_name',
                'attribute'=>'service_name',
                'value'=>'serviceName.services',

            ],
           // 'room_category',
            [
                'attribute'=>'room_category',
                'value'=>'roomCategory.room_category'
            ],
            'charges_cash',
            'charges_cashless',

            ['class' => 'yiigridActionColumn'],
        ],
         'showFooter' => true
    ]); ?>

</div>

Looking for some help on this one. Thanks.

解决方案

I think you just need to add the page summary;

use kartikgridGridView;

// Create a panel layout for your GridView widget
echo GridView::widget([
    'dataProvider'=> $dataProvider,
    'filterModel' => $searchModel,
    'columns' => $gridColumns,
    'showPageSummary' => true
]);

Kartik describes it pretty well in the demo and plugin details.

这篇关于Yii2:Kartik Gridview 页脚中一列的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Yii2:Kartik Gridview 页脚中一列的总和

基础教程推荐