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

weird error with the sorting of multiple columns #98

Open
xJuvi opened this issue May 28, 2024 · 1 comment
Open

weird error with the sorting of multiple columns #98

xJuvi opened this issue May 28, 2024 · 1 comment

Comments

@xJuvi
Copy link

xJuvi commented May 28, 2024

Hey there,,

I have a problem where I don't know exactly how best to describe or show it.

I have a very complex query over several different tables with joins. The columns in the select command are arbitrarily ordered, because the sorting in JavaScript is done by data attribute. The sorting is defined in JavaScript and has two columns.

Now I have included the column id (is the auto increment column of the main table) and placed it at the beginning of the select query. Now only the second part of the sorting is applied, then the sorting is done by id in ascending order. After I put the id in the select query at the end and the two columns to be sorted by at the beginning, everything works.

before change (already working)

$dt->query("select g.firstname, g.lastname, g.email, g.birthdate, g.lastbooking, g.lastimpartattempt, g.registerdate  from guest g join event e [....]");

after change (only second filter is working)

$dt->query("select g.id, g.firstname, g.lastname, g.email, g.birthdate, g.lastbooking, g.lastimpartattempt, g.registerdate  from guest g join event e [....]");

now (everything is working again)

$dt->query("select  g.lastbooking, g.lastimpartattempt, g.firstname, g.lastname, g.email, g.birthdate, g.registerdate, g.id  from guest g join event e [....]");

My JavaScript defines the following order:

order: [
			['3', 'asc'],
			['4', 'asc']
			],
		"columns": [
			{"data": "lastname"},
			{"data": "firstname"},
			{"data": "birthdate"},
			{"data": "lastimpartattempt"},
			{"data": "lastbooking"},
			]

But after adding the id, only the column 4 was working, column 3 was ignored and the guests are sorted by id.

Do you have any problem? How can i help you to troubleshoot this issue?

Kind regards

@n1crack
Copy link
Owner

n1crack commented Jun 1, 2024

this is interesting.. I need to look into it. btw, I've updated broken docs .

It can be unrelated, I don't know but:

// ❌  i think, the first parameter should be integer

order: [
    ['3', 'asc'],
    ['4', 'asc']
  ],


// ✅   like this: 

order: [
    [3, 'asc'],
    [4, 'asc']
  ],

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