Page 1 of 1

Sorted list in depselect widget

PostPosted: Wed Dec 07, 2011 10:13 am
by alexchet
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?

Re: Sorted list in depselect widget

PostPosted: Wed Dec 07, 2011 10:42 am
by shannah
I think you should be able to set the -sort parameter in the widget def:
Code: Select all
widget:filters:-sort="city, hname"

Re: Sorted list in depselect widget

PostPosted: Sat Dec 10, 2011 10:00 pm
by alexchet
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.

Re: Sorted list in depselect widget

PostPosted: Mon Dec 12, 2011 1:59 pm
by shannah
Thanks for posting this.

Re: Sorted list in depselect widget

PostPosted: Mon Dec 12, 2011 3:33 pm
by shannah
I have added this change to the SVN trunk rev 3109.

Re: Sorted list in depselect widget

PostPosted: Thu Jun 21, 2012 3:02 pm
by Ciao121
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 :)