Table column sorting in Plone 5

In Plone 4.3.4, I used a javascript, which I think was sortable.js to be able to sort our tables by columns. We used this for a table in our intranet as well as for a table that lists job openings. Can this be done in Plone 5?

Any JS can be used in Plone 5.
If you are working on a theme, just put your JS in your Diazo. If you are working on an add-on, declare your JS in a bundle (see this example https://github.com/collective/example.p4p5).

This is a common pattern and a class to achieve it was available in Plone 4; IIRC, .

@vangheem just told me the other day we have a pattern available to do such thing in Plone 5, but I can't remember the name.

This need to be documented.

There may be a good case for taking some of what is documented in mockup examples and moving to docs.plone.org?

Anyway, I think this is the pattern you are looking for: http://plone.github.io/mockup/dev/#pattern/tablesorter

...which is not to be confused with the "sortable" pattern (which is for manual item re-ordering of lists and tables).

Sean

I'm back to this again. I put my sortable.js in my Diazo theme. Since I'm trying to make the headers on a table that's part of collection sortable, I thought I needed to modify my tabular_listing template also. I put a new file called the same thing as the original template (listing_tabular) into the "template_overrides" of my product. In the template, I just removed the "nosort" class on the "th" and also changed the table class to = "sortable" as per the instructions on http://www.kryogenix.org/code/browser/sorttable/ for this javascript. I'm trying to sort the columns on this page: http://www.met.psu.edu/careers/job-listings/us-and-canada-job-listings. It's not working. Any thoughts?

The tablesorter-pattern was removed for Plone 5.0b4 in https://github.com/plone/mockup/commit/e4cf1efb since Plone itself does not use it.

Was this moved to a different package that can installed on its own, or just deleted? I have a lot of plone 4 templates with tables using the "listing" class so I'm looking for a Plone 5 solution for them.

Tons of add-ons used it....major compatibility foul.

-aj

2 Likes

The tablesorter was too limited for most cases. We are using ag-grid.com in most of our new Plone 5 projects (coming from Datatables.net from JSGrid).

-aj

I was able to use this in my Plone 5 site. http://www.kryogenix.org/code/browser/sorttable/