1
CDbActiveRecord 설정이 있고 위젯으로 CGridView 클래스 설치 인스턴스가 있습니다.Yii, CGridView의 각 요소에 하나씩 unquie ids 생성
기본적으로 내 게임은 테이블이 필요하지만 각 행은 활성 레코드와 연결된 행의 기본 키를 포함해야합니다.
예를 들면 :
내가 찾고 행의 특정의<tr id="123"> <td> Column value 1 </td> <td> Col 2 </td> <td> Col 3 </td> </tr>
.
다음은 지금까지 테이블을 생성하는 코드입니다. (이 컨트롤러 내부와 위젯은 JSON으로 반환되기 때문에 JSON 변수가 설정됩니다.)
// get the content id for the version list
$contentID_v = Yii::app()->request->getParam("id");
// setup the criteria to fetch related items
$versionCdbCriteria = new CDbCriteria;
$versionCdbCriteria->compare("contentID",$contentID_v);
// setting up the active data provider for the version
$vActiveDP = new CActiveDataProvider("FactsheetcontentVersion", array(
"criteria" => $versionCdbCriteria,
'pagination' => array('PageSize' => $this->paginationSize),
'keyAttribute'=>'vID',
));
$json_data .= $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $vActiveDP,
'columns' => array(
'title',
'created',
'createdBy'
),
'showTableOnEmpty' => 'false',
),true);
이 내 활성 레코드를 생성하는 것입니다.
<div class="grid-view" id="yw0">
<div class="summary">Displaying 1-1 of 1 result(s).</div>
<table class="items"><thead>
<tr><th id="yw0_c0">Factsheettitle</th>
<th id="yw0_c1"><a href="jq/work/admin/index.php?r=factsheetManager/Editor
&id=25601&getV=true&_=1341694154760&FactsheetcontentVersion_sort=created">Created</a>
</th>
<th id="yw0_c2"><a href="jq/work/admin/index.php?r=factsheetManager/
Editor&id=25601&getV=true&_=1341694154760&FactsheetcontentVersion_sort=createdBy">Created By</a>
</th>
</tr></thead>
<tbody><tr class="odd"><td>Distribution</td><td>0000-00-00 00:00:00</td><td>NULL</td></tr></tbody>
</table>
<div title="jq/work/admin/index.php?r=factsheetManager/Editor&id=12&id=25601&getV=true&_=1341694154760" style="display:none" class="keys"><span>8</span></div>
</div>
지금은 작동하는 해킹 솔루션을 발견 : http://stackoverflow.com/a/11096827 –
CGridView를 확장해야합니다. 고유 한 행 ID가 필요한 이유는 무엇입니까? 다른 해결 방법이있을 수 있습니다 .. –