Open hardik-creolestudios opened 10 years ago
Can you please check following solution and tell is it proper or not ? Solution: -> Changed in ordering function of \vendor\bllim\datatables\src\Bllim\Datatables\Datatables.php
-> Please check edited code and old code which is comment in following code.
protected function ordering()
{
if(array_key_exists('order', $this->input) && count($this->input['order'])>0)
{
$columns = $this->clean_columns( $this->last_columns );
for ( $i=0, $c=count($this->input['order']); $i<$c ; $i++ )
{
$order_col = (int)$this->input['order'][$i]['column'];
if (isset($columns[$order_col])) {
if ( $this->input['columns'][$order_col]['orderable'] == "true" )
{
#Old code#
//$this->query->orderBy($columns[$order_col],$this->input['order'][$i]['dir']);
#Old code#
#Edited code#
$this->query->orderBy($this->input['columns'][$order_col]['data'],$this->input['order'][$i]['dir']);
#Edited code#
}
}
}
}
}
This fixed issue for me on column sorting when using ColReorder extension.
@rustyfb24 Can you please show an snippet or any example link which shows how to use ColReorder extension ?
You might want to look into the new dataFullSupport option in the latest version. There's a new example on using it in the docs. It relies less on the column order, and primarily on the column names set as the "data" property. It should allow you to return all the columns you need for both uses with the same url.
For multiple datatables which are using same url to fetch data with slightly difference in columns' e.g. In below datatables check and compare columns and ajax properties. -> ajax properties url is same except one extra argument but they calls same method. -> column properties first columns are different. so while ordering it is not properly getting order ================ First ==================================== var tbl_reports = $('#tbl_reports').dataTable({ "bLengthChange": false, "processing": false, "serverSide": true, "ajax": "<?php echo URL::route('reports-list',array('business_id'=>$id));?>", "bFilter": false, "columns": [ {"data": "name", "width": "15%", "name":"name" }, {"data": "reported_on", "width": "15%", "mRender": function(data, type, full) { return moment.utc(data).fromNow(); } }, {"data": "amount", "width": "15%", "mRender": function(data, type, full) { return "$"+data; } }, {"data": "bussiness_conduct", "width": "15%", 'sorting': false}, {"data": "disciplined_by", "width": "15%", 'sorting': false}, {"data": "details", "width": "5%", 'class': "alignCenter", 'sorting': false} ]
});
==========================Second================================
var tbl_reports = $('#tbl_reports').dataTable({ "bLengthChange": false, "processing": false, "serverSide": true, "ajax": "<?php echo URL::action('reports-list');?>", "bFilter": true, "columns": [ {"data": "bussiness_name", "width": "15%"}, {"data": "name","width": "15%"}, {"data": "reported_on", "width": "15%", "mRender": function(data, type, full) { return moment.utc(data).fromNow(); } }, {"data": "amount", "width": "15%", "mRender": function(data, type, full) { return "$"+data; }, 'sorting': false }, {"data": "bussiness_conduct", "width": "15%", 'sorting': false}, {"data": "disciplined_by", "width": "15%", 'sorting': false}, {"data": "details", "width": "5%", 'class': "alignCenter", 'sorting': false} ]
});