gride view for fetch images

<?= GridView::widget([
‘dataProvider’ => $dataProvider,
‘filterModel’ => $searchModel,
‘columns’ => [
[‘class’ => ‘yii\grid\SerialColumn’],

‘category_id’=>[
‘label’=>’Category Id’,
‘value’=>function($data) {
return $data->category_id;
}

]
,

‘category_name’=>[
‘label’=>’Category Name’,
‘value’=>function($data) {
return $data->category_name;
}

]
,
‘category_createdat’=>[
‘label’=>’Category Created At’,
‘value’=>function($data) {
return $data->category_createdat;
}

],
//’category_photo’
‘category_photo’=>
[
‘label’ => ‘Item Photo’,
‘format’ => [‘image’,[‘width’=>’100′,’height’=>’100’]],

‘value’=>function($data) {
return ‘../’.$data->category_photo;

 

// return Html::img(‘../../’.$data->category_photo, // return the img
// [‘width’ => ’60px’]);

}
],

‘category_updatedat’=>[
‘label’=>’Category Updated At’,
‘value’=>function($data) {
return $data->category_updatedat;
}

 

],

[‘class’ => ‘yii\grid\ActionColumn’],
],
]); ?>

</div>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s