@@ -126,9 +126,7 @@ public function applyToTable($options)
126126
127127 if (isset ($ options ['hiddenColumns ' ]) && is_array ($ options ['hiddenColumns ' ])) {
128128 // first display all columns,
129- foreach ($ this ->columns as $ key => $ column ) {
130- $ this ->columns [$ key ]['hidden ' ] = false ;
131- }
129+ $ this ->resetHiddenColumns ();
132130
133131 // then hide all columns that should be hidden:
134132 foreach ($ options ['hiddenColumns ' ] as $ columnToHide ) {
@@ -166,6 +164,7 @@ public function applyToTable($options)
166164 public function resetTable ()
167165 {
168166 $ this ->perPage = config ('livewire-datatables.default_per_page ' , 10 );
167+ $ this ->sort = $ this ->defaultSort ();
169168 $ this ->search = null ;
170169 $ this ->setPage (1 );
171170 $ this ->activeSelectFilters = [];
@@ -175,9 +174,21 @@ public function resetTable()
175174 $ this ->activeBooleanFilters = [];
176175 $ this ->activeNumberFilters = [];
177176 $ this ->hide = null ;
177+ $ this ->resetHiddenColumns ();
178178 $ this ->selected = [];
179179 }
180180
181+ /**
182+ * Display all columns, also those that are currently hidden.
183+ * Should get called when resetting the table.
184+ */
185+ public function resetHiddenColumns ()
186+ {
187+ foreach ($ this ->columns as $ key => $ column ) {
188+ $ this ->columns [$ key ]['hidden ' ] = false ;
189+ }
190+ }
191+
181192 public function updatedSearch ()
182193 {
183194 $ this ->setPage (1 );
0 commit comments