如何为 CGridView 的每个表行分配唯一的 id 属性? [英] How to assign unique id attribute to each table row of a CGridView?
问题描述
我试图为 Yii 的 CGridView
中的每个表格行分配一个唯一的 ID.
I am attempting to assign a unique id to each table row in Yii's CGridView
.
最好是类似于数据库表中的 $data->id
.
Preferably something like $data->id
from the database table.
我未能成功为每个渲染的 I have been unsuccessful at adding an 任何建议将不胜感激. CGridView 有一个名为 'rowHtmlOptionsExpression' 的选项,你可以像下面这样声明为行分配一个 id CGridView have an option called 'rowHtmlOptionsExpression' , you can declare like the followings to assign row an id 这比侵入rowCssClassExpression"要好 It's better than hacking into 'rowCssClassExpression' 祝你好运! 这篇关于如何为 CGridView 的每个表行分配唯一的 id 属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! 添加 id
属性.
id
attribute to each rendered <tr>
.推荐答案
'rowHtmlOptionsExpression' => 'array("id"=>$data->id)',
登录
关闭