Yii2 - Search link in the gridview not working

Ashikur Rahman

In my yii2 project, I'm using Pjax GridView.

My index page:

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        'id',
        'batch',
        [
             'attribute' => 'file_import',
             'format' => 'raw',
             'value'=>function ($data) {
                return Html::a($data->file_import, ['/device/index', 'DeviceSearch', 'batch' => $data->batch]);
            },
         ],

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

The link in the file_import column goes to http://localhost/index.php/device/index?1=DeviceSearch&batch=200325806610154437. But in this url, all the data is showing instead of showing only the search result. I wanted to set the file_import column as an url which will show only the search result by the provided parameter in the url.

Thank you in advance.

Bizley

Change URL route to

['/device/index', 'DeviceSearch[batch]' => $data->batch]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related