insert static first row in cgridview yii

2019-08-10 15:30发布

my code in cgridview

    enter cod<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'party-ledger-grid',
    'dataProvider'=>$model->search(),
    'columns'=>array(
        'id',
             array(
                'name'=>'trans_date',
                'value'=> 'Yii::app()->dateFormatter->format("d-MMM-y",strtotime($data->trans_date))'
            ),
                'trans_id',
                array(
                        'name'=>'tr_type_id',
                        'value'=>'$data->trType->tr_code'
                    ),
.....

and result shown below:

enter image description here

My question is how to insert first static row in cgridview table after header, for previous balance. how to add static custom row in cgridview.

1条回答
聊天终结者
2楼-- · 2019-08-10 16:01

Actually you can't do this in simple way. There are 2 options:

  1. Generating row in javascript and appending it to table.

  2. using CArrayDataProvider instead of CAtiveDataProvider and appending to it first row that you will calculate. This method has more shortcomings.

I used first method when i faced this problem.

查看更多
登录 后发表回答