Sorting Table on Date fields

Teodor,

Here’s a video of the sort issues, form the ID to email fields all seem to sort fine.
Problem sort fields: Reg Date/Time, Travel, Ground, Hotel, Checkin, Checkout, Updated date, Admin

Thanks,
Amedeo

Wappler_sort_issues_Trim.mp4 (10.8 MB)

This is going to probably sound like a strange solution however if your database has fields that are just blank, i do no mean set to NULL, I mean totally blank in certain cells sometimes there is a strange display issue. What you need to do is set a default value for all cells to accommodate the blank fields. This normally seems to be an issue with paged queries, and is not really a bug as far as I know, just the way it works.

Lets say you have something like this

<td dmx-text="firstname"></td>

Then just add a default parameter to it like this

<td dmx-text="firstname.default('')"></td>

This will then ensure any blank fields queried from your data get a value on nothing within your page, you need to do this on all of your columns.

Please let me know if that sorts out the issue.

Thank you, that actually worked, but I would think it’s a bug, nulls and blanks should sort properly.

How would fix my date fields, they are formatted like this:

<td class="text-nowrap small" dmx-text="RegDate.formatDate(&quot;M-d-yyyy h:mm a&quot;)"></td></pre>

Hello @adicarlo
That’s not a bug, but it’s by intention and it is for rendering speed improvements.

As for your date field, try:

dmx-text="(RegDate.formatDate(&quot;M-d-yyyy h:mm a&quot;)).default('')"

I see, thanks Teodor. That worked!!!

for this reason i always set a default where possible within the database design, 0 or “” in place of nulls

2 Likes

I am looking at this post but I can’t seem to figure out how to sort by Date Field. Is there a step step instruction I can go through. Thanks much