row expression

Being able to set per row attribute expressions in GridView etc would be handy.

I’m trying to add a value attribute (I know it’s not valid) so it can be used by some js and i’m currently using

'rowCssClassExpression' => '"\" value=\"" . $data->dataID'

which doesn’t look too elegant.

I needed this too and ended up extending CGridView. I had to completely override renderTableRow and I’m not too fond of it either.

public function renderTableRow($row) {

	$data = $this->dataProvider->data[$row];

	if($this->rowTitleExpression !== null)

		$title = CHtml::encode($this->evaluateExpression($this->rowTitleExpression, array(

			'row' => $row,

			'data' => $data


	if($this->rowCssClassExpression !== null)

		echo '<tr class="'.$this->evaluateExpression($this->rowCssClassExpression, array(

			'row' => $row,

			'data' => $data


		($title ? ' title="'.$title.'"' : '').'>';

	else if(is_array($this->rowCssClass) && ($n = count($this->rowCssClass)) > 0)

		echo '<tr class="'.$this->rowCssClass[$row % $n].'"'.

		($title ? ' title="'.$title.'"' : '').'>';


		echo '<tr>';

	foreach($this->columns as $column)


	echo "</tr>\n";


IMPORTANT: If somebody’s using this, please note that you won’t get a title-tag when there is no rowCssClass- or rowCssClassExpression-property!

So yes, I too think that would be a useful feature!