Gridview loaded dinamically by ajax with expand row column extension doesn’t work
Hello,
I habe a tabx that loads through ajax the gridview rendered using renderAjax method.
The gridview contains an “expand row column” that does not expand in any row.
When i try to load the same grid directly without ajax request and using renderPartial all works fine.
It seems that the assets of the “expand row column” widget are not loaded.
That is the item of the tabx
Start your code here
[
‘label’=>'<i class=”glyphicon glyphicon-briefcase”></i> ‘.Yii::t(‘db’,’Items’),
‘content’=>”.”,
‘active’=>$mode==’item’?true:false,
‘linkOptions’=>[‘data-url’=>Url::to([‘/job-management/item-by-id’,’id’=>$model->idJob])],
],
that is the action
Start your code here
//JOB ITEM MANAGEMENT
public function actionItemById($id){
….
$ajax = Yii::$app->request->isAjax;
if($ajax)
{
return Json::encode($this->renderAjax(‘/job-management/item’, [
‘dataProvider’ => $dataProvider,
‘model’ => $model
]));
}else {
return $this->renderPartial(‘/job-management/item’, [
‘dataProvider’ => $dataProvider,
‘model’ => $model
]);
}
}
That is the gridview
Start your code here
<?php Pjax::begin();?>
<?= GridView::widget([
‘dataProvider’ => $dataProvider,
‘pjax’=>0,
‘persistResize’ => false,
‘responsive’ => true,
‘hover’ => true,
‘toolbar’ => [
],
‘panel’ => …
‘columns’ => [
…
[
‘class’ => ExpandRowColumn::className(),
‘value’ => function ($model, $key, $index, $column) {
return GridView::ROW_COLLAPSED;
},
‘detailUrl’ => Url::to([‘job-management/item-expanded-detail’]),
‘expandIcon’ => ‘<span class=”glyphicon glyphicon-link”></span> <span class=”glyphicon glyphicon-expand”></span>’,
‘collapseIcon’ => ‘<span class=”glyphicon glyphicon-link”></span> <span class=”glyphicon glyphicon-collapse-down”></span>’,
‘headerOptions’ => [‘class’ => ‘kartik-sheet-style’],
‘expandOneOnly’ => true
],
…
],
]); ?>
<?php Pjax::end();?>
Thanks
Matteo
The post Gridview loaded dinamically by ajax with expand row column extension doesn't work appeared first on Krajee Web Tips.