Sortable columns with EasyCrudRestController setup

25 views
Skip to first unread message

Dax Mitchell

unread,
Oct 30, 2018, 4:28:37 PM10/30/18
to TurboGears
We are using CrudRestControllerConfig and EasyCrudRestController to do our UI, including tabular representation of the underlying SQLite tables (via SQLAlchemy).  

We have a table with a foreign key relationship, e.g., Movies table with Genre column pointing at the Genres table.  

Is there a way to enable sorting of the foreign key column (e.g., sort on 'Genre' on the Movies data grid)?

It looks like these get skipped at the following point in the code.  Perhaps there's a way to override this behavior?

I would be grateful for any suggestions on how to enable sorting on such columns in the TurboGears or Sprox frameworks.

Alessandro Molina

unread,
Nov 6, 2018, 9:31:51 AM11/6/18
to TurboGears
Might be possible.
I vaguely remember that the Provider supports sorting for related entities based on the field names on SQLAlchemy (but not non Mongo).

If you are willing to experiment with what happens when that check is removed I'm open to merging any pull request that might be required to get rid of that limitation.

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+...@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Alessandro Molina

unread,
Nov 8, 2018, 6:47:07 AM11/8/18
to TurboGears
I verified and as I suspected the required changes for SQLAlchemy were very minimal.
It was mostly disabled because it wasn't supported on MongoDB. 

I wrote a quick pull request to make it work on MongoDB 3.2+: https://github.com/TurboGears/sprox/commit/c8af03152d7548fdef589935d961aaab61765061
I'll make a new tgext.crud+sprox release as soon as I have the time to write specific tests for this and document the new requirement over MongoDB>=3.2 if mongo is used.

Alessandro Molina

unread,
Nov 14, 2018, 6:54:33 PM11/14/18
to TurboGears
tgext.crud 0.9.0 was just released with support for sorting over related entities: https://github.com/TurboGears/tgext.crud/releases/tag/0.9.0

Dax Mitchell

unread,
Nov 16, 2018, 11:34:50 AM11/16/18
to TurboGears
Awesome!  This is very much appreciated!
Reply all
Reply to author
Forward
0 new messages