tgext.crud sorting on child table fields

15 views
Skip to first unread message

Craig Small

unread,
May 9, 2013, 5:00:57 PM5/9/13
to TurboGears .
I've hit another little speed-bump with the jqgrid in the admin screens.
Say you have two tables, Parent and Child with a relationship between
them. One column I want to show is Parent.child and this works fine (the
trick is to use __possible_field_names__ set to whatever you want
to see from the child, in my case the column called display_name

Anyhow that bit works, I can see my grid filled with things, I click
on the id or name of the parent and the json call changes the sidx
field in the url (sord index) to "id" or "name".

When I click child, I'd want to sort the rows by child name, the call
back to the json url is sidx=child which is sort-of right from the
grid's point of view. The backend (TableFiller) gets a SQLA error
because child is not a real column in parent, its a relationship.

Now, outside tgext.crud I would of probably hand-crafted a join to bring
in the Child table and made the order_by Child.display_name but I cannot
see how it is done within this object.

It's probably a bigger thing than a jqgrid problem, can you make direct
json calls to tgext.crud and sort on these child fields?

- Craig
--
Craig Small VK2XLZ http://enc.com.au/ csmall at : enc.com.au
Debian GNU/Linux http://www.debian.org/ csmall at : debian.org
GPG fingerprint: 5D2F B320 B825 D939 04D2 0519 3938 F96B DF50 FEA5

Moritz Schlarb

unread,
May 10, 2013, 6:04:28 AM5/10/13
to turbo...@googlegroups.com, csm...@enc.com.au
IIRC, sorting on relationships like this isn't possible at the moment, but it's right on the roadmap...

Craig Small

unread,
May 10, 2013, 6:20:53 AM5/10/13
to turbo...@googlegroups.com
On Fri, May 10, 2013 at 03:04:28AM -0700, Moritz Schlarb wrote:
> IIRC, sorting on relationships like this isn't possible at the moment, but
> it's right on the roadmap...
I've got it working. I can see the standard turbogears admin controller
doesn't let you do it but even if it did, sprox is broken in that area
so it wouldn't work. I'll attach the sprox patch to the bug report
I've reported on it.

That means a very small fix for tgext.admin too to send the possible
columns on its way.
Reply all
Reply to author
Forward
0 new messages