瀏覽代碼

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

jqh 5 年之前
父節點
當前提交
9a82d0ec5a
共有 1 個文件被更改,包括 9 次插入3 次删除
  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>";
     }