[英]orderColumn for sorting not working in yajra datatable using in laravel
OrderColumn not working for sorting the list according to updated_at but not working. OrderColumn 无法根据 updated_at 对列表进行排序,但无法正常工作。
This is my code you can see这是我的代码你可以看到
$product = Product::query()->get();
return Datatables::of($product )
->orderColumn('updated_at', 'DESC')
->make(true);
Javascript code Javascript代码
<script>
$(document).ready(function(){
var columns = [
{
data: 'name',
name: 'name',
searchable: true
},
columns.push({
data: 'action',
name: 'action',
orderable: false,
searchable: "false",
className: "text-center"
});
$('#product-table').DataTable({
pageLength: 25,
processing: true,
serverSide: true,
ajax: {
url: '{{ route('products.dt') }}',
},
columns: columns,
});
});
</script>
The problem is that JQuery Datatables is performing its own sort after receiving the data.问题是 JQuery 数据表在接收数据后正在执行自己的排序。 So the sort on the server is ignored.
所以服务器上的排序被忽略。
I have run into the same issue, but have not yet found a solution.我遇到了同样的问题,但还没有找到解决方案。 I am thinking about adding an extra hidden column to sort the data, but this is not a great solution either.
我正在考虑添加一个额外的隐藏列来对数据进行排序,但这也不是一个很好的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.