pkjoshi
(Info)
1
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' => 'yii\grid\SerialColumn'],
'id',
[
//'attribute'=>'service_name',
'attribute'=>'service_name',
'value'=>'serviceName.services',
],
[
'attribute'=>'room_category',
'value'=>'roomCategory.room_category'
],
'charges_cash',
'charges_cashless',
['class' => 'yii\grid\ActionColumn']
];
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' => 'yii\grid\SerialColumn'],
'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' => 'yii\grid\ActionColumn'],
],
'showFooter' => true
]); ?>
</div>
Thanks in advance for your valuable help.
Hi, you have to add ‘pageSummary’=>true, to the column.
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
//'service_name',
[
//'attribute'=>'service_name',
'attribute'=>'service_name',
'value'=>'serviceName.services',
],
// 'room_category',
[
'attribute'=>'room_category',
'value'=>'roomCategory.room_category',
],
[
'attribute'=>'charges_cash',
'pageSummary'=>true,
],
'charges_cashless',
['class' => 'yii\grid\ActionColumn'],
],
'showFooter' => true
]); ?>
for more details see http://demos.krajee.com/grid-demo#configure
pkjoshi
(Info)
3
Hi Abed,
I have done the modification, I am getting the footer row, but no total in the column.
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
[
'attribute'=>'service_name',
'value'=>'serviceName.services',
],
[
'attribute'=>'room_category',
'value'=>'roomCategory.room_category'
],
[
'attribute'=>'charges_cash',
'pageSummary'=>true
],
'charges_cashless',
['class' => 'yii\grid\ActionColumn'],
],
'showFooter'=>True,
]); ?>
amirajlo
(Amirajlo)
4
Hi My Friend
I use below way and it work:
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'price',
'pageSummary' =>true,
// 'pageSummary' => \app\components\PTotal::pageTotal($dataProvider->models,'price'),
'pageSummaryFunc' => GridView::F_SUM,
'vAlign' => 'middle',
'headerOptions' => ['class' => 'kv-sticky-column'],
'contentOptions' => ['class' => 'kv-sticky-column'],
'editableOptions' => ['header' => 'price', 'size' => 'md']
],