Lookup Filed - Date and sorting

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
User avatar
RonP
Veteran Member
Posts:319
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Lookup Filed - Date and sorting

Post by RonP » 2026-01-21 15:58

Hi,
I've a sorting issue.
I've defined a Lookup Field that refers to a date field

As I sort, by <tabel_view.php> the sort is done in order of DAY instead of the complete date field.

Do I miss a "selector field" somewhere?

Ron
01-Date sort defined.png
01-Date sort defined.png (28.9 KiB) Viewed 5791 times
02-Definition Date - Lookup Field.png
02-Definition Date - Lookup Field.png (275.85 KiB) Viewed 5791 times
03-Date sort.png
03-Date sort.png (40.67 KiB) Viewed 5791 times

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts:1464
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Lookup Filed - Date and sorting

Post by onoehring » 2026-01-24 09:49

Hi Ron,

this seems to be like a bug ... AG pulls a date - thus, it should provide a list, that can be sorted as date. It seems to sort it as a string value.
Consider posting as a bug?
Olaf

User avatar
RonP
Veteran Member
Posts:319
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Lookup Filed - Date and sorting

Post by RonP » 2026-01-24 14:35

Hi onoehring

Thank you, I'll post it as a possible bug.

Ron

saymaad
AppGini Super Hero
AppGini Super Hero
Posts:131
Joined: 2024-06-03 16:17

Re: Lookup Filed - Date and sorting

Post by saymaad » 2026-01-26 10:36

Hi Ron,

With which version of AppGini are you having this issue? I tried sorting from the table view header and the filter page, on AppGini 23.17 it works as intended without any bug:
Screenshot 2026-01-26 143404.png
Screenshot 2026-01-26 143404.png (22.28 KiB) Viewed 5586 times
-Saymaad

User avatar
RonP
Veteran Member
Posts:319
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Lookup Filed - Date and sorting

Post by RonP » 2026-01-26 11:15

Hi saymaad ,

I'm using 2 versions same results:
V25.15 and V26.10 (the later in develop and stage testing)

Ron

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts:1757
Joined: 2018-04-01 10:12

Re: Lookup Filed - Date and sorting

Post by pbottcher » 2026-03-06 16:15

Hi Ron,
not sure I see your problem. In the image that you posted, the sorting looks ok. What would you expect?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
RonP
Veteran Member
Posts:319
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Lookup Filed - Date and sorting

Post by RonP » 2026-03-06 16:55

Hi pbottcher,
Thanks for reaching out.
In my first post I show the result after sorting, click column name.
The results come back sorted by day, so first all the 01 days of ALL months, then the 02 days etc.
The sort is, according to me, bases on a charachter sort instead of a date sort.
Ron

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts:1464
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Lookup Filed - Date and sorting

Post by onoehring » 2026-03-06 17:13

Hi Ron,
well, could you please post another screenshot showing the problem. I agree with pboetcher, that the first screenshot does not allow us - strangers - to see something wrong ;-) Thanks

Olaf

User avatar
RonP
Veteran Member
Posts:319
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Lookup Filed - Date and sorting

Post by RonP » 2026-03-07 09:26

Olaf,
I know see that I’ve provided a not good example, sorry.
Hereby a better example, column: “Datum aanvraag”
IMG_0191.png
IMG_0191.png (238.19 KiB) Viewed 5385 times

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts:1464
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Lookup Filed - Date and sorting

Post by onoehring » 2026-03-07 09:55

HI Ron,

to all in the thread: Ron is showing a lookupfield that contains (correct) an integer value (PK of referenced table) - maybe that's the reason? Is the field actually being shown sorted by the value of the ID field (and it only looks to use that ist' sorted by day first, then month...)?
Can someone reproduce this?

@Ron: What happens, when you click the header in a field that actually is of type date or datetime?
@Ron: Did you set any field specific formating (tab more right)?

Olaf

User avatar
RonP
Veteran Member
Posts:319
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Lookup Filed - Date and sorting

Post by RonP » 2026-03-07 14:00

Olaf,

@Ron: What happens, when you click the header in a field that actually is of type date or datetime?
That sorts as expected.

@Ron: Did you set any field specific formating (tab more right)?
No

01 Basetable Aanvragen.jpg
01 Basetable Aanvragen.jpg (79.84 KiB) Viewed 5371 times
01-1 Basetable sort OK.jpg
01-1 Basetable sort OK.jpg (63.03 KiB) Viewed 5371 times
02 Table defenition with look-up.jpg
02 Table defenition with look-up.jpg (76.17 KiB) Viewed 5371 times
02.1 dependend table sort not OK.jpg
02.1 dependend table sort not OK.jpg (138.79 KiB) Viewed 5371 times

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts:1757
Joined: 2018-04-01 10:12

Re: Lookup Filed - Date and sorting

Post by pbottcher » 2026-03-07 16:38

Hi Ron,

thanks, that helps.

I agree that this is a bug, as AppGini is using the formated date for sorting, when using the date as lookup, instead of the original date.

What you can try as a workarround is:

Go to the hooks/coachbozoeke.php file an add to the _init function a replacement for the sorting.

You can try to set : $options->SortFields[NUMBEROFYOURFIELD]1="`SOURCETABLE`.`SOURCEFIELD`";

which, if i read the images correctly and your fields did not move positions would result in:

Code: Select all

$options->SortFields[7]="`aanvragen1`.`Datum_aangevraagd`";
Watch the 1 after the SOURCETABLENAME, this is needed as AppGini adds per lookup to the sourcetable a "counter".

If you have multiple lookups from the coachbozoeke to the aanvragen table, you may need to check the concret "counter".

To do so you may add to the _init function, right at the start:

echo "<pre>";var_dump($options->SortFields);exit;

Call the page and look at the output.
you should see somewhere
date_format(`aanvragenX`.`Datum_aangevraagd`,
use the X from this entry as the counter mentioned above.


Hope I did read the name correctly.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
RonP
Veteran Member
Posts:319
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Lookup Filed - Date and sorting

Post by RonP » 2026-03-08 12:35

Hi pbottcher,

GREAT, ik works.
Sorted date Look-up.jpg
Sorted date Look-up.jpg (91.32 KiB) Viewed 5346 times
Ron

Thank you, hopefully there will be a next version/build of AppGini.

Post Reply