Whats the recommended way to have javascript based filtering and sort table views in a plugin tab?

Is is possible to use garnish to do that or should we be looking at external libraries like:


  • I'm interested in this as well. We're you able to find anything?
    – nateiler
    Commented Dec 16, 2014 at 4:02
  • Seems like the only way to use the built in sorting is by using an element type. Commented Dec 16, 2014 at 4:06

1 Answer 1


I don't believe that there is a recommended way to do this, so I'll attempt to answer this question as best I can.

By using an element type, you will be able to use the element index layout for free, with very little setup. That will give you access to native sorting and searching (filtering), along with a bunch of other things such as grouping, statuses, table and thumbnail views, etc. Creating your element type template is as simple as including the following 3 lines:

{% extends "_layouts/elementindex" %}
{% set title = "ElementName"|t %}
{% set elementType = 'PluginName_ElementName' %}

There is not way that I know of to natively allow sorting of a table without using an element type and it doesn't look like Garnish offers this functionality.

So I guess the only way at present to make this work with JavaScript is to use an external library such as tablesorter or as you mentioned DataTables.

  • Any news to this during these 7 years? I got the design down by adding the data class to the table-element, but I cannot find out how to reuse the sorting functionality.
    – PWL
    Commented Jun 14, 2022 at 6:47

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.