adding new column but unable to sort it using orderColumn.
Aatmik-Coder opened this issue · comments
Summary of problem or feature request
I want to sort a column which is not present in the database table, but is calculated on the basis of column present in the table.
Code snippet of problem
->addColumn('pot_size', function($row) {
$get_Draw = $row->draw_number??"";
$get_player = $row->total_players;
$total_player = $get_player;
if($get_Draw){
$get_player = UserResults::where(['game_id'=>$row->id,'draw_number'=>$get_Draw])->count('user_id');
if($total_player > $get_player){
$difference_player = $total_player - $get_player;
return ($row->price * $total_player * $get_Draw + $row->price) - $difference_player;
}
return $row->price * $total_player * $get_Draw + $row->price;
}
return $row->price * $total_player + $row->price;
})
->orderColumn('pot_size', function ($query, $order) {
$query->orderBy('pot_size', $order);
})
js
{data: 'pot_size', name:'pot_size', searchable:false},
as from the above code you can see that the pot_size is dependent on price, players, and on particular draw. The pot_size value is correctly visible but I am unable to sort it.
I have searched many solution online but couldn't find the proper solution for it.
System details
- Operating System : windows
- PHP Version: 8.2.0
- Laravel Version: 10.10
- yajra/laravel-datatables-oracle: ^10.6
- Laravel-Datatables Version
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been inactive for 7 days since being marked as stale.