Page 1 of 1

5.92: Setting DEFAULT SORT ORDER in AG and an order in _init fails

Posted: 2021-01-07 13:42
by onoehring
Hi,

I have set a default sort order in AG.
When I set an additional sort order in the _init function (hooks/tablename.php -> ) the page is not displayed at, but I get an error thrown.
AG Setting:
l8.png
l8.png (7.36 KiB) Viewed 3829 times
Code in _init:

Code: Select all

$options->DefaultSortField = 'JobFertiggestellt DESC, Log_Fertig_Zeit DESC, BenoetigtAm ASC, ID_Container_Platz_aktuell DESC';
SQL in the error shown, when I open the page (I am marking the wrong SQL - so unfortunately I can not use the code-tag) - there is an extra desc added. I would think if I define an extra $options->DefaultSortField the AG application would/should ignore the settings from AG:
-----------------------
SELECT
... all my fields...
FROM
... my table/joins ...
ORDER BY
JobFertiggestellt DESC,
Log_Fertig_Zeit DESC,
BenoetigtAm,
ID_Container_Platz_aktuell DESC
desc
LIMIT 0, 50
-----------------------

I am not sure if this also happens when I do not set descending as sortorder in AG.

Olaf

Re: 5.92: Setting DEFAULT SORT ORDER in AG and an order in _init fails

Posted: 2021-01-07 15:57
by pbottcher
Hi,
I would assume it does not happen if you do not set the default sorting.

For your case, try to leave out the last desc in the init function.

Re: 5.92: Setting DEFAULT SORT ORDER in AG and an order in _init fails

Posted: 2021-01-08 08:30
by onoehring
Hi pbötcher,

I actually set the default sort order in AG by accident :-) ... but I would think it's a but that the described happens.

Have a great and healthy new year
Olaf