Predefined order not works.
Predefined order not works.
![mkpanchal](https://secure.gravatar.com/avatar/c9d3b769758bc938608eb13620d289ef/?default=https%3A%2F%2Fvanillicon.com%2Fc9d3b769758bc938608eb13620d289ef_200.png&rating=g&size=120)
Link to test case:
http://demo.caseclosed.cloud
Login : info@appuno.co
Pwd : P@ssw0rd
Navigate to Module -> Case
In this i have used it same.
Debugger code (debug.datatables.net):
$("#caseMainTable").DataTable({
"fnRowCallback": function (nRow, data, iDisplayIndex, iDisplayIndexFull) {
if (data.IsRead == false)
{
$('td', nRow).css('color', 'orangered');
}
},
"responsive": true,
"destroy": true,
"processing": true,
"colReorder": { order: [6,1,2,3,4,5,0,7,8,9,10] },
"serverSide": true,
"order": [[3, "desc"]],
"lengthMenu": [
[10, 25, 50, 100, -1],
['10 rows', '25 rows', '50 rows', '100 rows', 'Show all']
],
"dom": 'Bfrtip',
"buttons": ['pageLength',
{
extend: 'excelHtml5',
autoFilter: true,
sheetName: 'Exported data',
exportOptions: {
columns: ':visible'
}
}],
"columnDefs": [
{ responsivePriority: 1, targets: 0 },
{ responsivePriority: 2, targets: [-1,-2,-3] },
{ targets: -1, className: 'text-center align-middle' },
{
targets: '_all',
render: $.fn.dataTable.render.ellipsis(20, true, false)
}
],
"ajax": $.fn.dataTable.pipeline({
"url": "/Case/loadCaseGrid",
"data": {
caseStatus: ischk,
region: regionv,
type: typev,
subtype: subtypev,
agent: Agentv,
caseActive: active,
caseInactive: inactive,
caseDel: isdel,
AppCase: isApp,
UnAppCase: isUnApp,
PendCase: isPnApp
},
"cache": false,
"type": "POST",
"datatype": "json"
}),
"columns": [
{
"title":'Approved ?',
"data": "IsApproved",
"visible":true,
"searchable": false,
"sortable": false,
"render": function (data, type, full, meta) {
if (data == "Approved") {
return '<span title="Approved"><i class="fa fa-thumbs-up" style="color:#227e77"></i></span>';
}
else if (data == "Disapprove") {
return '<span title="Disapproved"><i class="fa fa-thumbs-down" style="color:#ef5350"></i></span>';
}
else {
return '<span title="Pending"><i class="fa fa-exclamation-circle" style="color:#d39e00"></i></span>';
}
}
},
{ "title":'Case #', "data": "caseNumber", "autoWidth": true,"visible":true, },
{ "title":'Description', "data": "caseDescription", "autoWidth": true,"visible":true, },
{
"title":'Register Date',
"data": "caseOpenDate",
"visible":true,
"autoWidth": true,
"render": function (data, type, row) {
if (data == null) {
return "";
}
if (type === 'display' || type === 'filter') {
return (moment.utc(data).format("DD-MMM-YYYY"));
}
return data;
}
},
{ "title":'Status', "data": "status", "autoWidth": true,"visible":true, },
{ "title":'Type', "data": "type", "autoWidth": true,"visible":true, },
{ "title":'Sub Type', "data": "subType", "autoWidth": true,"visible":true, },
{ "title": 'Region', "data": "CaseRegion", "autoWidth": true,"visible":true, },
{ "title": 'Stage', "data": "Stage", "autoWidth": true,"visible":true, },
{ "title": 'Original Complaint', "data": "OriginalComplaint", "autoWidth": true,"visible":true, },
{ "title":'Assign To Agents', "data": "AssignAgent", "autoWidth": true,"visible":true, },
{
"title": "Action",
"searchable": false,
"sortable": false,
"data": null,
"render": function (data, type, full, meta) {
var status = full.status;
var Perm = '<a href="#" onclick="DownloadCase(\'' + full["caseId"] + '\')" title="Download"> <i class="fas fa-download" style="color:#227e77;font-size:1.5em"></i></a>';
Perm += '<a href="#" onclick="ConverttoPdf(\'' + full["caseId"] + '\' )" title="PDF"> <i class="far fa-file-pdf" style="color:red;font-size:1.5em"></i> </a>';
if ('True' == "True" && full["IsDeleted"] == "0") {
Perm += '<a href="#" onclick="DelCase(0,\'' + full["caseId"] + '\')" title="Recover"> <i class="far fa-trash-restore" style="color:#227e77;font-size:1.5em"></i> </a>';
}
else {
if ('True' == "True")
{
Perm += '<a href="#" onclick="ConverttoPdf(\'' + full["caseId"] + '\')" title="PDF"></a>';
}
if ('True' == "True")
{
if (status == "Closed")
{
if('True' == "True")
{
Perm += '<a href="#" onclick="AddEditCase(\'' + full["caseId"] + '\')" title="Open"> <i class="far fa-edit" style="color:#227e77;font-size:1.5em"></i> </a>';
}
}
else
{
Perm += '<a href="#" onclick="AddEditCase(\'' + full["caseId"] + '\')" title="Open"> <i class="far fa-edit" style="color:#227e77;font-size:1.5em"></i> </a>';
Perm += '<a href="#" onclick="RelCase(\'' + full["caseId"] + '\')" title="Related Case"> <i class="fas fa-retweet" style="color:#227e77;font-size:1.5em"></i> </a>';
}
}
if ('True' == "True" && full["IsDeleted"] == "1")
{
Perm += '<a href="#" onclick="DelCase(1,\'' + full["caseId"] + '\')" title="Delete"> <i class="far fa-trash-alt" style="color:red;font-size:1.5em"></i> </a>' ;
}
Perm += '<a href="#" onclick="RemoteReview(\'' + full["caseId"] + '\')" title="Remote Review"> <i class="fa fa-link" style="color:yellowgreen;font-size:1.5em"></i> </a>';
}
return Perm;
}
}
]
})
Error messages shown:
No
Description of problem:
I have set the column predefined order but it display the standard order.
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
I just took a look and it looks like it's honouring
"order": [[3, "desc"]],
to me - all the tables are sorted byRegister date
which is in the 4th position incolumns
(note counts are from 0).Why do you think it's not working?
Colin