从 Yii2 高级模板 Gridview 获取值过滤器

Getting value Filter From Yii2 advanced template Gridview

这是我的代码:

index.php

<?= Html::a('Download Excel',NULL, ['class' => 'btn btn-primary','onclick'=>'
          var query;
          $.ajax({
            type: "GET",
            url:"'.Url::to(['excel']).'",
            data:query,
            success:function(response){
              response = response.replace(/^\s+|\s+$/g,"");
              location.href = response;
            }
          })
']) ?>

<?php Pjax::begin(['id' => 'pjax-gridview']) ?>
<?= GridView::widget([
    'dataProvider' => $dataProvider2,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],

        //'m_id',
        [
          'attribute'=>'ins_id',
          'format' => 'text',
          'filter' => ArrayHelper::map($data,'ins_id','ins_nama'),
          'value' => function($data){
                $ins = new Instansi();
                $nama = $ins->find()->where(['ins_id'=>$data->ins_id])->one();
                return $nama->ins_nama;
          },
        ],
        'm_kegiatan',
        'm_location',
        [
          'attribute'=>'m_sifat',
          'format' => 'text',
          'filter' => Array('baru' => 'Baru', 'lanjutan' => 'Lanjutan', 'rehab' => 'Rehab', 'perluasan' => 'Perluasan'),
        ],
        'm_volume',
        [
          'attribute'=>'m_biaya',
          'format' => 'text',
          'value' => function($data){
                return 'Rp. '.number_format($data->m_biaya,'0',',','.');
          },
        ],
        //'created_by',
        //'created_at',
        //'updated_by',
        //'updated_at',
        //'m_status',
    ],
]); ?>
<?php Pjax::end() ?>

我想从网格视图过滤器中获取值,例如当我在网格上添加过滤器时,索引 URL 将变为 localhost/frontend/controller_name/index?ModelSearch[name]=filter_value

所以我的 ajax 的 URL 将是 localhost/frontend/controller_name/excel?ModelSearch[name]=filter_value

但我不知道如何从 gridview 过滤器中获取值,我尝试使用 Pjax id 进行序列化,但它现在可以工作了,也许你们可以帮忙?

'Url::to(['excel'])' 会变成 'Url::to(['excel', Html::getInputName($ searchModel,'name'])=>Html::getAttributeValue($searchModel,'name')])'

在 Html 标记之前启动您的 PJax 小部件,这样当 Gridview 搜索触发 PJax 时 link 也会更新