【问题标题】:Yii2 - How to remove blank space from Gridview FilterYii2 - 如何从 Gridview 过滤器中删除空格
【发布时间】:2018-08-15 11:21:06
【问题描述】:

我有这个网格视图

我想用All替换状态上的空格,这样它就会有All, Active, Inactive

视图:网格视图

            [
            'class' => '\pheme\grid\ToggleColumn',
            'contentOptions' => ['class' => 'text-center'],
            'attribute'=>'is_status',
            'enableAjax' => false,
            'filter'=>['1'=>'InActive', '0'=>'Active'],
        ],

我如何做到这一点?

【问题讨论】:

  • 尝试再添加一个选项,例如'filter'=>['' => All, '1'=>'InActive', '0'=>'Active'],
  • 我这样做了,但空白区域仍然存在。我不想要那里的空白。

标签: yii2


【解决方案1】:

使用filterInputOptions

[
   'class' => '\pheme\grid\ToggleColumn',
   'contentOptions' => ['class' => 'text-center'],
   'attribute' => 'is_status',
   'enableAjax' => false,
   'filter' => ['1' => 'InActive', '0' => 'Active'],
   'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => 'All'],
],

【讨论】:

    猜你喜欢
    • 2017-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-10
    • 2012-10-20
    • 2015-02-17
    • 2020-05-23
    相关资源
    最近更新 更多