Browse Source

增加第三次点击取消表格排序功能

jqh 5 years ago
parent
commit
9a82d0ec5a
1 changed files with 9 additions and 3 deletions
  1. 9 3
      src/Grid/Column/Sorter.php

+ 9 - 3
src/Grid/Column/Sorter.php

@@ -84,9 +84,15 @@ class Sorter implements Renderable
             $sort['cast'] = $this->cast;
         }
 
-        $url = request()->fullUrlWithQuery([
-            $this->sortName => $sort
-        ]);
+        if (! $this->isSorted() || $this->sort['type'] != 'asc') {
+            $url = request()->fullUrlWithQuery([
+                $this->sortName => $sort
+            ]);
+        } else {
+            $url = request()->fullUrlWithQuery([
+                $this->sortName => [],
+            ]);
+        }
 
         return " <a class=' glyphicon glyphicon-sort{$icon} $color' href='$url'></a>";
     }