insert static first row in cgridview yii

♀尐吖头ヾ 提交于 2019-12-11 11:54:51

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/19182182/insert-static-first-row-in-cgridview-yii

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!