How to sort my datatable with multiple columns criteria but not common parameters.
How to sort my datatable with multiple columns criteria but not common parameters.
Hello! I'm sorry to not be able to provide a test case. My data comes from a database with multiple JOINS and i don't know how to replicate but I'll take pictures of my localhost datatable.
The problem I'm facing is that I see a lot of Questions solved about sorting and multi sorting of the database but none of those examples does what I need. I have a datatable that shows the orders on an online sell business,
In the shown datatable, I have 3 criterias to sort. First and most important is the green one "ESTADOS" or STATES Column where the users see if there are products on the order, if the order is for the current day, past days or following days; or if the order still has missing data (ex. payment method not defined). Its the most important because if the order is marked as "completed" or "canceled" I want the order to go all the way down the datatable no mather what;
Then I have the Yellow one which shows who attended that customer (Title of the column is "Atiende" or attends in English). It's important because, of those orders that are not marked as Completed/Cancelled I want that each user of the system see on top the customers that he attends, and then the customers from other users.
Third but not less important, we have the date(column "FECHA").. Here is where I kind of don't know if what I want is possible (even when I don't know how to sort with the previous 2 criterias)... I need that if the orders are not marked as completed/canceled and they have PAST Dates get on top, no mather who is the user who attends that order, because that means that the business failed in attending that order by the date agreed. Those orders must be attended first... After that, I want the orders from "TODAY" to show, and only after those, the orders that go to following days in order.
To summarize, I need to see:
First: all the orders with past date, that are not marked as completed or cancelled no mather the user.
Second: All the orders that are for today AND that I, as user, am attending.
Third: All the orders that are for today AND that are being attended by other users, ordered by user name if possible.
Fourth: All the orders that are for later days. Sorted by date as first criteria, and sorted by user as second criteria.
I know it's a lot of text here, I have tried a lot of ordering and sorting methods, but I think the problem outsmarts me as I'm new to datatables...
Thanks for your time! and sorry for my bad English!
This question has an accepted answers - jump to answer
Answers
You could look at the SearchBuilder extension, as that's capable of all those searches. Also, you can load pre-defined searches (see here) and with
searchBuilder.rebuild()
you can allow the user to load searches at the click of a button (example here)Colin
Thank you! I tried using that solution but it made the function of "Filter" I needed to Sort, not to Filter. Anyway I solved the problem by creating a new Column with Column.render() and returning numbers if certain criteria is met. Thanks!