Browse Source

调用expand(false)可以禁止自动弹出过滤器侧栏

jqh 4 years ago
parent
commit
27e4355584
2 changed files with 5 additions and 3 deletions
  1. 4 2
      src/Grid/Filter.php
  2. 1 1
      src/Grid/Tools/FilterButton.php

+ 4 - 2
src/Grid/Filter.php

@@ -144,7 +144,7 @@ class Filter implements Renderable
     /**
      * @var bool
      */
-    public $expand = false;
+    public $expand;
 
     /**
      * @var Collection
@@ -464,7 +464,9 @@ class Filter implements Renderable
 
         return tap(array_filter($conditions), function ($conditions) {
             if (! empty($conditions)) {
-                $this->expand();
+                if ($this->expand === null || $this->mode !== static::MODE_RIGHT_SIDE) {
+                    $this->expand();
+                }
 
                 $this->grid()->fireOnce(new ApplyFilter([$conditions]));
 

+ 1 - 1
src/Grid/Tools/FilterButton.php

@@ -49,7 +49,7 @@ class FilterButton extends AbstractTool
         $id = $filter->filterID();
 
         if ($filter->mode() === Filter::MODE_RIGHT_SIDE) {
-            if ($this->filter()->grid()->model()->getCurrentPage() > 1) {
+            if ($filter->grid()->model()->getCurrentPage() > 1) {
                 $expand = 'false';
             } else {
                 $expand = $filter->expand ? 'true' : 'false';