Print Image In Gridview Return Error

Hi

I am trying to print image in gridview but i had below error , if I print it in view page all things work :unsure: , so

what’s wrong ?




<?php

$assetsDir = Helper::UPLOAD_DOMAIN_URL . Helper::PRODUCT_UPLOAD_FOLDER . Helper::Countries;

?>


$this->widget('application.components.GridView.BSGridView', array(

	'id' => 'countries-grid',

	'dataProvider' => $model->search(),

	'filter' => $model,

	'columns' => array(

    	'co_id',

    	'country',

    	'country_e',

    	'country_f',


    	'code',

    	array(

        	// 'value'=>'Yii::app()->request->baseUrl."/upload/".$data->image'

        	'name' => 'image',

        	'type' => 'html',

        	'value' => '(!empty($data->image))?CHtml::image($assetsDir$data->image),"",array("style"=>"width:25px;height:25px;")):"no image"',


    	),


    	array(

        	'class' => 'XCButtonColumn',

        	'template' => '{view} {delete} {update} {CitesManagement}',

        	'buttons' => array(

            	'CitesManagement' => array(

                	'label' => Yii::t('app', 'Cites.Management'),

                	'html' => '<i class="icon-th-list"></i>',

                	'options' => array('class' => 'btn btn-default',

                    	),

                	'url' => 'Yii::app()->createUrl("cities/admin", array("country_id"=>$data->co_id))',


            	),

        	),

    	),

	),

	'template' => '{items}',

	'cssFile' => Yii::app()->theme->baseUrl . '/Theme/html/css/bootstrap/bootstrap.css',

	'itemsCssClass' => 'table table-striped table-bordered table-hover dataTable',

	'pager' => array(

    	'class' => 'CustomLinkPager',

    	'cssFile' => Yii::app()->theme->baseUrl . '/Theme/html/css/bootstrap/bootstrap.css',

    	'htmlOptions' => array('class' => 'pagination')

	),

	'pagerCssClass' => 'dataTables_paginate paging_bootstrap pagination',

	'summaryCssClass' => 'dataTables_info'

)); ?>



Thanks in advance

Hi please see this wiki

I hope it’s some help.

I think there’s a dot (.) missing between [font=“Courier New”]$assetsDir[/font] and [font=“Courier New”]$data->image[/font].

Hi

first of all set in the column


'type'=>'raw'

second you have an error with dot, also what is $assetsDir ? ($assetsDir$data->image)

set it in your controller and use it like that


'type'=>'raw',

  'value' => 

'(!empty($data->image)) ? CHtml::image($this->grid->controller->assetsDir . "/" . $data->image),"",array("style"=>"width:25px;height:25px;")):"no image"',

Hi Thanks all to help but all soultios not worked , @Ankit Modi I read it before thank you .

KonApaz my friend thank for help , I tried your solution but not worked for you question , I uploaded images in another domain

so assetsDir result will be exactly on my localhost like this :

assetsDir = http://localhost/upl...iles/countries/

So what do you think ?

[b]

[/b]

I fixed it and this my code :rolleyes::




array('name' =>'image','filter'=>false, 'value' => 'CHtml::link(

        	CHtml::image(Helper::UPLOAD_DOMAIN_URL . Helper::PRODUCT_UPLOAD_FOLDER . Helper::Countries . $data->image, $data->image, array("width"=>32,"height"=>32)),

        	Helper::UPLOAD_DOMAIN_URL . Helper::PRODUCT_UPLOAD_FOLDER . Helper::Countries . $data->image,array("id"=>"add"))',

        	'type' => 'raw',

    	),




Thanks All