我有卡蒂克gridView和自定义过滤器。在浏览器中使用网格过滤器后,我得到了如下URL
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=有没有办法从YII内部的url中删除未填充的参数,而不是javascript?或者有人能提供完整的javascript示例来实现目标。
发布于 2022-02-26 13:56:49
将vendor/yiisoft/yii2/yii.gridView.js复制到web目录下的某个位置(例如,web/js并添加以下一行:
$.each(data, function (name, value) { if (value[0].length === 0) data[name] = null; });在applyFilter方法中的这一行前面:
var pos = settings.filterUrl.indexOf('?');然后将其添加到web.conf (如果您对这个js文件使用了不同的位置,则更新路径):
'assetManager' => [
'bundles' => [
'yii\grid\GridViewAsset' => [
'sourcePath' => '@webroot/js',
'basePath' => '@webroot/js',
'baseUrl' => 'vendor/js',
],
],
],这是因为您没有修改vendor文件夹中的任何内容。
https://stackoverflow.com/questions/70214410
复制相似问题