Sorted list in depselect widget

Archived from the Xataface Users forum.

alexchet — Wed Dec 07, 2011 10:13 am

Hi,
I use depselect widget which is populated from table hospitals

Code: Select all
`[hospitalid]

widget:type = depselect
widget:table=hospitals`

The table is ordered by sql request,

Code: Select all
__sql__ = "select * from hospitals ORDER BY city, hname"

but I get unsorted dropdown list in depselect widget.
Is there any way get ordered one?


shannah — Wed Dec 07, 2011 10:42 am

I think you should be able to set the -sort parameter in the widget def:

Code: Select all
widget:filters:-sort="city, hname"

alexchet — Sat Dec 10, 2011 10:00 pm

To get sorted list we need to pass id - labels pairs as nonassociative array. So to solve the problem I have to edit depselect.js and depselect_load.php files.
See attachment.


shannah — Mon Dec 12, 2011 1:59 pm

Thanks for posting this.


shannah — Mon Dec 12, 2011 3:33 pm

I have added this change to the SVN trunk rev 3109.


Ciao121 — Thu Jun 21, 2012 3:02 pm

If I use:

Code: Select all
[provincia_nascita] widget:label = "Provincia di nascita" widget:description = "Scegliere la provincia di nascita" widget:type = depselect widget:table=province order = 3

I have no problem but if I add

Code: Select all
widget:filters:-sort="nomeprovincia"

I get a pop up error:

Code: Select all
SintaxError: missing; before statement

and no data in the select box.

I alredy uploaded the atthacched files on the server.
Any idea?

Thank you