How do I sort by Date and Status type ?
How do I sort by Date and Status type ?
![Sakifabu](https://secure.gravatar.com/avatar/f7530545e3ad358030c14bc594f776e4/?default=https%3A%2F%2Fvanillicon.com%2Ff7530545e3ad358030c14bc594f776e4_200.png&rating=g&size=120)
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