I have a CDbActiveRecord setup and I have a instance of the CGridView class setup as a widget.
Basically my end game is I need a table, but each row to contain the primary key of the row associated with the Active Record.
Such as:
<tr id="123"> <td> Column value 1 </td> <td> Col 2 </td> <td> Col 3 </td> </tr>
That's the specific of the row that I'm looking for.
Here's the code I've got so far to produce a table. (The json variable is set because this is inside a controller and the widget is returned as 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);
This is what it produces for my active record.
<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>