I have a Dojo DataGrid fed by a json response at http://localhost/json/
You can sort this DataGrid by any column. When I tell the DataGrid I want
to sort by, say sticker_id, the DataGrid sends another request to
/json/?sort(+sticker_id).
Currently, I am handling this by pulling the parameter name from
web.input() (since there is no value) and parsing it like so:
s = "sort(+sticker_id)" # String after retrieval of parameter
s = s[5:-1] # s == "+sticker_id"
if s[0] == '+'
order_by = s[1:] + " ASC"
if s[0] == '-'
order_by = s[1:] + " DESC"
then I run something like db.select("myTable" order=order_by)
and eventually json dump the data.
Does it work? Yes. But I feel like there is a better and more pythonic
way to do this. Does anyone have any tips to point me in the right
direction?
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/webpy/-/UM-Ha1Ka0R0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.