How do I sort by Date and Status type ?
How do I sort by Date and Status type ?
I have been trying to Sort the table by two columns one by date time which i can do by using the order attribute but the other is by status which is proving to be a bit more difficult. This is what I have so far
$(document).ready(function () {
var table = $("#RequestDetSubmittedReq").DataTable({
responsive: true,
//paging: true,
fixedColumns: true,
ordering: true,
columnDefs: [
{
width: '20%', targets: 0
},
{
targets: [5],
orderData: [5, 6]
},
{
targets: [6],
orderData: [5, 6]
}
],
"order":[[5, "desc"],[6,"asc"]],
"language":
{
"emptyTable": "There are currently no submitted request"
}
});
});
The Data Consists of one of these (Pending/rejected/Approved) this on column 6.
The table is being created by razor and Datatable is being used on client side only.
Answers
Hi @Sakifabu ,
Yep, you'll need to convert those status strings to something ordering in
columns.render
. This example here should help.Cheers,
Colin