File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -12,16 +12,28 @@ trait WithColumnSelect
12
12
public bool $ columnSelect = false ;
13
13
public array $ columnSelectEnabled = [];
14
14
15
+ public bool $ usesSelect = false ;
16
+
15
17
public function mountWithColumnSelect (): void
16
18
{
17
19
// If the column select is off, make sure to clear the session
18
20
if (! $ this ->columnSelect && session ()->has ($ this ->getColumnSelectSessionKey ())) {
19
21
session ()->forget ($ this ->getColumnSelectSessionKey ());
20
22
}
21
23
24
+ $ selected = collect ($ this ->columns ())
25
+ ->filter (fn ($ column ) => $ column ->isSelected ())->count ();
26
+
27
+ if ($ selected > 0 ) $ this ->usesSelect = true ;
28
+
22
29
// Get a list of visible default columns that are not excluded
23
30
$ columns = collect ($ this ->columns ())
24
- ->filter (fn ($ column ) => $ column ->isVisible () && $ column ->isSelectable () && $ column ->isSelected ())
31
+ ->filter (function ($ column ) {
32
+ if ($ this ->usesSelect ) {
33
+ return $ column ->isVisible () && $ column ->isSelectable () && $ column ->isSelected ();
34
+ }
35
+ return $ column ->isVisible () && $ column ->isSelectable ();
36
+ })
25
37
->map (fn ($ column ) => $ column ->column ())
26
38
->values ()
27
39
->toArray ();
You can’t perform that action at this time.
0 commit comments