Reputation: 244
I have Kartik gridView and custom filter. After gridfilter in my browser i got URL like
localhost:20024/consignment?fid=&post_code=&pud2_mrn=&pud2_status=PUDP&pud_status=&pud2_remaining_date=&mrn=&mrn_status=&ioss_number=&declaration_type=&status=&entry_at=&exit_at=&created_at=
Is there a way to remove unfilled parameters from url inside YII instead javascript? Or can anybody provide full example of javascript to achieve the goal.
Upvotes: 1
Views: 486
Reputation: 2576
Copy vendor/yiisoft/yii2/yii.gridView.js
somewhere under web
directory (e.g. web/js
and add this line:
$.each(data, function (name, value) { if (value[0].length === 0) data[name] = null; });
prior this line in applyFilter
method:
var pos = settings.filterUrl.indexOf('?');
Then add this to web.conf
(update paths if you used different place for this js file):
'assetManager' => [
'bundles' => [
'yii\grid\GridViewAsset' => [
'sourcePath' => '@webroot/js',
'basePath' => '@webroot/js',
'baseUrl' => 'vendor/js',
],
],
],
This was you are not modifying anything in the vendor
folder.
Upvotes: 1