I saved some data in json format into my database in one field called json. I used widget in order to display full list of products.
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'page-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'name',
'json',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
I decoded field (called json
) which contains json data. And I am going to use a value of decoded json(p_1 element of decoded json (json["p_1"]))
in the widget instead of whole field (called json
).
(Because fields(called json
) contains a lot of data and I need only one data). How can I use p_1 instead of field(called json
)?
You can pass a php expression as the value to be displayed.
$data
represents the data model for the row.Reference: http://www.yiiframework.com/doc/api/1.1/CDataColumn#value-detail