How could I use the dataReader to show data in the CGridView? Is there any way to "convert" a CDbDataReader into a data provider? Or am I definitely forced to avoid the CGridView in this case?
I would like to avoid having to manually build my CGridView-like table fetching the query results using a php foreach.
Suggestion for a different approach are welcome too!
I decided to use CSqlDataProvider and it is working OK, but I can’t make reference to the $data property on the CGridView definition, which I can use just fine if I use a CActiveDataProvider as the CGridView data provider.
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
array(
'name'=>'field1',
'header'=>' My Field 1',
),
array(
'header'=>'My Field 1 Again',
'value'=>'$data->field1',
),
),
));
In this example, the column “My Field 1” works OK, but the column “My Field 1 Again” shows blank data. Am I doing something wrong? I have to use the ‘value’ property because I need to make additional formatting work to the value I am getting from the data provider.