mehdi nejati
mehdi nejati

Reputation: 346

yii framework image path for TbImageColumn

i use component of bootstrap.widgets.TbExtendedGridView in yii framework.i have table with name of places that image path save it.i want show image in the grid view. i use CSqlDataProvider and grid columns:

$dataprovider1= new CSqlDataProvider("select Name,Type,Distance,ByCar,OnFoot,conact('$adminPath','/',Image) as Image from places where ParentId = '$_GET[ParentId]' AND Kind='$kind[id]'");

$gridcolumns1=array(
         //array('name'=>'img','type'=>'html'),
         array( 'class'=>'bootstrap.widgets.TbImageColumn',
                'imagePathExpression'=>'$data->Image',
                'usePlaceKitten'=>FALSE
               ),
        array('name'=>'Image','header'=>'name'),
        array('name'=>'Type','header'=>'type '),
        array('name'=>'Distance','header'=>'distance'),
        array('name'=>'ByCar','header'=>'bycar'),
        array('name'=>'OnFoot','header'=>'onfoot'),           

        ); 

this is my gridview:

 $this->widget('bootstrap.widgets.TbExtendedGridView',array(
            'type'=>'striped bordered',
            'dataProvider'=>$dataprovider1,
            'template'=>"{items}",
            'columns'=>  $gridcolumns1
        ));  

everything is ok but grid view cannot show image.

Upvotes: 2

Views: 1549

Answers (1)

mehdi nejati
mehdi nejati

Reputation: 346

I found the solution to be:

array( 'class'=>'bootstrap.widgets.TbImageColumn',
                'imagePathExpression'=>'$data[Image]',
                'usePlaceKitten'=>FALSE
               ),

Upvotes: 1

Related Questions