Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple value coloumn order #78

Closed
reidsneo opened this issue May 28, 2021 · 2 comments
Closed

Multiple value coloumn order #78

reidsneo opened this issue May 28, 2021 · 2 comments

Comments

@reidsneo
Copy link

Dear Maintainer,

I have issue with multiple value order issue
for example while using query like this :
SELECT * FROM ticket_table ORDER BY status='Open' DESC, status='In Progress' DESC, status='On Hold' DESC, status='Closed' DESC"`

Which the result should be show on following order
No Name Status
5 Blabla Open
2 Blabla Open
3 Blabla Open
6 Blabla In Progress
7 Blabla In Progress
1 Blabla On Hold
8 Blabla On Hold

but it displayed in normal squence instead, it seem in generate() method set a new index instead using as is as result from mysql

Thanks!

@n1crack
Copy link
Owner

n1crack commented May 28, 2021

Actually, it is the expected behaviour of the library. That's how sorting works.

If you want to keep sorting as it is on init, you should leave a blank array to "order" settings of datatables in javascript.

 "order": []

I think it is the best way to set a default sorting order is setting "order" variable in javascript, and remove "order by" statements from sql, so php library can add the statement accordingly.

        $(document).ready(function() {
            $('#example').dataTable( {
                "serverSide": true,
                "ajax" : "/public/ajax.php",
                "order" : [
                    [1, "asc"],
                    [2, "desc"]
                ]
            });
        });

@reidsneo
Copy link
Author

Thank you!, it seem I missed the "order" part and "aaSorting" part, what I expect is the library will do the ordering part for init, but the js configuration mess it up, I will close the issue now thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants