ordering rank(id) based on another column value #2517
Replies: 4 comments
-
Just do a multiple column ordering? ->order([
[4, 'desc'],
[0, 'asc']
]) |
Beta Was this translation helpful? Give feedback.
-
That's my builder data right now, but still not working after i added the order as you suggested. return $this->builder()
->columns($this->getColumns())
->minifiedAjax()
->parameters([
'dom' => 'Bfrltip',
'order' => [
[0, 'ASC'],
[2, 'DESC'],
],
'orderable' => true,
'responsive' => true,
"processing" => true,
"info" => true,
"searching" => true,
'select' => false,
"lengthMenu" => [[10, 25, 50, 100, 200, -1], [10, 25, 50, 100, 200, __('datatables.show-all')]],
'language' => [
'search' => __('datatables.search'),
'zeroRecords' => __('datatables.zero'),
"info" => __('datatables.info'),
"infoEmpty" => __('datatables.empty'),
"infoFiltered" => __('datatables.info-filtered'),
"paginate" => [
"first" => __('datatables.first'),
"last" => __('datatables.last'),
"next" => ">",
"previous" => "<"
],
'searchPlaceholder' => __('datatables.searchPlaceholder'),
'lengthMenu' => __('datatables.length'),
'processing' => __('datatables.processing'),
],
'buttons' => [
'reload',
'print',
'colvis',
],
]); |
Beta Was this translation helpful? Give feedback.
-
Just note that you must convert all your ordering via SQL If the value is computed outside the query, then I think it's impossible to sort on both columns. You can try using collection and sorting of computed column would work. However, do note that it is prone to performance issue when your dataset is large. |
Beta Was this translation helpful? Give feedback.
-
i did it as collection but i had to disable the ordering from the third column (it's number 2) because i will missorder if there are 2 cols with the same value |
Beta Was this translation helpful? Give feedback.
-
Hello, i wanna ask a little question
how to make ranking (id, the first column) based on another column value
as example in this picture i'm ordering by "Rank" and it's ASC ordering while the ItemPoints is ordered DESC


but if i click on ItemPoints to Order by it the Rank column is getting disordered because there are many columns with the same value inside ItemPoints as you can see in this picture,
so is there a way to connect these two columns with each others to show the same result?
PS: i'm using HTML Builder with Columns
and that's the columns code
Thanks
Beta Was this translation helpful? Give feedback.
All reactions