6

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:

http://www.datatables.net/

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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