简体   繁体   中英

insert static first row in cgridview yii

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:

在此处输入图片说明

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM