3

Is it possible to sort two (or more) tables independently in a single view?

I have two tables in a view: one through CBV SingleTableView (Table A) and one passed in through the context (Table B). When trying to sort Table B, the correct url is passed e.g. https//:..../?sort=delivery_date however it seems it is being consumed by Table A. If the column name does not exist in Table A, nothing happens, if it does exist in Table A, Table A is sorted rather than Table A.

I can understand this behaviour as nothing is posted to identify the originating table. My question is, is there any support for independent multiple table per view sorting?

Thanks in advance Nathan

1 Answer 1

3

Well that was easy...

It was in the docs of course: I needed to add a prefix to my second table:

...
config = RequestConfig(self.request)
table2 = ot.UnfulfilledSalesOrderTable(om.SalesOrder.objects.filter(
    status__fulfilled=False, status__cancelled=False), self.request,
    prefix="2-")
config.configure(table2)
...

This adds a prefix to the querystring like so ?sort=ship_date&2-sort=number which achieves exactly the functionality I am after.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.