I would like to have my CGridView(i.e. my admin.php) show only data in which one of the columns is empty or null.
How can I achieve that
I would like to have my CGridView(i.e. my admin.php) show only data in which one of the columns is empty or null.
How can I achieve that
Any Ideas?
Extend CGridView and override the method renderTableRow($row). See the source
/**
* Renders a table body row.
* @param integer $row the row number (zero-based).
*/
public function renderTableRow($row)
{
foreach($this->columns as $column)
{
if(... check for empty value ...)
//see function CdataColumn::renderDataCellContent($row,$data) how extract the value
return; //if empty column found
}
parent::renderTableRow($row);
}
will this code be in the model or controller?
Maybe I don’t understant your problem… but why you just don’t add the needed condition to get only those rows you need
You have to create a own CGridView class and save it for example under protected/components
Yii::import('zii.widgets.grid.CGridView');
class EmptyColumnsGridView extends CGridView
{
public function renderTableRow($row)
{
//... like above
}
}
And in your view:
$this->widget('EmptyColumnsGridView', array(
'dataProvider'=>$dataProvider,
....
But if you are able to query only the data with empty columns (see remark from mdomba) it would be better.
But maybe it depends on columns visibility, calculated data … etc.
I cannot change the needed condition as there is certain use of it but I do not want to show it’s row