-
Summary of problem or feature requestHello, I have the following problem: Code snippet of problemFrom the DataTable class I use the builder public function html() { return $this->builder() ->setTableId('users-table') ->addTableClass('vexor-dt-table') ->columns($this->getColumns()) ->minifiedAjax() ->dom('Bfrtip') ->language(['url' => '//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Hungarian.json']) ->responsive(true) ->autoWidth(false) ->orderBy([8,1], 'asc') ->columnDefs([ ['responsivePriority' => 1, 'targets' => -1], ]) ->rowGroupDataSrc('department_id') ->lengthMenu([25, 50, 100, 200]) ->buttons( Button::make(['extend' => 'create', 'text' => '<i class="fas fa-plus"></i> ' . trans('global.app_add_new'), 'className' => 'btn-outline-success']), Button::make(['extend' => 'excel', 'text' => '<i class="fas fa-file-excel"></i> ' . trans('global.app_excel'), 'className' => 'btn-outline-info']), Button::make(['extend' => 'pdfHtml5', 'orientation' => 'landscape', 'text' => '<i class="fas fa-file-pdf"></i> ' . trans('global.app_pdf'), 'className' => 'btn-outline-info']), Button::make(['extend' => 'print', 'text' => '<i class="fas fa-print"></i> ' . trans('global.app_print'), 'className' => 'btn-outline-info']), Button::make(['extend' => 'reload', 'text' => '<i class="fas fa-sync-alt"></i> ' . trans('global.app_reload'), 'className' => 'btn-outline-info']), Button::make(['extend' => 'pageLength', 'text' => '<i class="fas fa-list"></i> ' . trans('cafeteria_settings.words.home.rows'), 'className' => 'btn-outline-info']), ); } And in the Trait, your code is this (HasOptions.php orderBy function) public function orderBy($index, $direction = 'desc') { if ($direction != 'desc') { $direction = 'asc'; } if (is_array($index)) { $this->attributes['order'][] = $index; } else { $this->attributes['order'][] = [$index, $direction]; } return $this; } I managed to "fix" the problem with this foreach public function orderBy($index, $direction = 'desc') { if ($direction != 'desc') { $direction = 'asc'; } if (is_array($index)) { foreach ($index as $values){ $this->attributes['order'][] = [$values, $direction]; } } else { $this->attributes['order'][] = [$index, $direction]; } return $this; } But it's a bad fix, for overwrite something in vendor. Thanks, for the help! System details
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Use ->order([[8, 'asc'], [1, 'asc']]) |
Beta Was this translation helpful? Give feedback.
Use
order
instead oforderBy