[英]Create Custom Row in yii Cgridview
I had created a yii Cgridview but how to make custom row in the it. 我创建了一个yii Cgridview,但是如何在其中创建自定义行。 I want to make the custom row whose data is static not related to database?
我要使自定义行的数据是静态的,与数据库无关吗? the problem is similar to below
问题类似于下面
http://www.yiiframework.com/forum/index.php/topic/47751-insert-first-row-in-cgridview/ http://www.yiiframework.com/forum/index.php/topic/47751-insert-first-row-in-cgridview/
insert static first row in cgridview yii 在cgridview yii中插入静态第一行
Check this grid row 检查此网格行
array(
'name'=>'some_name',
'value'=>'$data->getCountryNameOrStaticStringOrWhatever()',
),
In model 在模型中
public function getCountryNameOrStaticStringOrWhatever(){
return 'my static content or whatever';
}
you can do it with javascript and jQuery: 您可以使用javascript和jQuery来做到这一点:
add 'afterAjaxUpdate' => 'addStaticRaw',
to CGrid config 在
'afterAjaxUpdate' => 'addStaticRaw',
配置中添加'afterAjaxUpdate' => 'addStaticRaw',
and register js script: 并注册js脚本:
function addStaticRaw(){
$('#party-ledger-grid tbody tr:first').before("<tr><td>Your static raw blah blah</td></tr>");
}
I was looking for a similar solution and came across this: 我在寻找类似的解决方案,并遇到了这个问题:
$this->widget('zii.widgets.grid.CGridView', array( 'id'=>'something', 'dataProvider'=>$provider, 'columns'=>array( array( 'name' => 'name', 'header' => 'Name', 'footer' => 'name column for extra row', ), array( 'name' => 'email', 'header' => 'e-Mail', 'footer' => 'email column for extra row' ), ) )
Simply fill out the footer elements of each column with the data from you extra row. 只需使用额外行中的数据填写每列的页脚元素。
It works like a charm! 它就像一个魅力!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.