0
我想在yii2網格視圖中實現運行總數。我在下面嘗試過,但我無法完全達到預期的結果。數據來自活動的數據提供者。在Yii2 gridview中累計/運行總數
$runningtotal = 0;
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'pjax' => true,
'columns' => [
[
'class' => '\kartik\grid\DataColumn',
'attribute' => 'pax',
'format' => 'decimal',
'pageSummary' => true
],
[
'value' => function ($model, $key, $index, $widget) use($runningtotal){
$runningtotal+= ($model->pax);
return $runningtotal;
},
'class' => '\kartik\grid\DataColumn',
'label' => 'Running Total',
'attribute' => 'paxtotal', //'format' => 'decimal',
],
],
]);
我的挑戰是在這個gridview上運行總數。