Answers.Body: <p>I don't believe that there is a <em>recommended</em> way to do this, so I'll attempt to answer this question as best I can. </p>
  
  <p>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:</p>
  
  <pre><code>{% extends "_layouts/elementindex" %}
  {% set title = "ElementName"|t %}
  {% set elementType = 'PluginName_ElementName' %}
  </code></pre>
  
  <p>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 <a href="https://github.com/pixelandtonic/Garnish/tree/master/Source/classes" rel="nofollow">Garnish</a> offers this functionality.</p>
  
  <p>So I guess the <em>only</em> way at present to make this work with JavaScript is to use an external library such as <a href="http://tablesorter.com/docs/" rel="nofollow">tablesorter</a> or as you mentioned <a href="http://www.datatables.net/" rel="nofollow">DataTables</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-14T06:47:06.650Z
Answers.Text: 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.
Answers.UserDisplayName: PWL
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-30T13:10:29.613Z
Answers.LastActivityDate: 2015-03-30T13:10:29.613Z
Answers.UserDisplayName: Ben Croker
Body: <p>Whats the recommended way to have javascript based filtering and sort table views in a plugin tab?  </p>
  
  <p>Is is possible to use garnish to do that or should we be looking at external libraries like:</p>
  
  <p><a href="http://www.datatables.net/" rel="noreferrer">http://www.datatables.net/</a></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-12-16T04:02:44.693Z
Comments.Text: I'm interested in this as well. We're you able to find anything?
Comments.UserDisplayName: nateiler
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-12-16T04:06:47.383Z
Comments.Text: Seems like the only way to use the built in sorting is by using an element type.
Comments.UserDisplayName: Keith Mancuso
Tags: <plugin-development><garnish>
Title: Filtering and sorting lists in a plugin
ThreadText: # Filtering and sorting lists in a plugin
  
  (Asked by: username_0 on 2014-09-29)
  
  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/>
  
  **Tags:** plugin-development, garnish
  
  > **Comments:**
  > **username_1**: I'm interested in this as well. We're you able to find anything?  
  > **username_0**: Seems like the only way to use the built in sorting is by using an element type.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-03-30. Score: 3 | Accepted answer
  
  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](https://github.com/pixelandtonic/Garnish/tree/master/Source/classes) 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](http://tablesorter.com/docs/) or as you mentioned [DataTables](http://www.datatables.net/).
  
  > **Comments:**
  > **username_3**: 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.  
  
  ---
  
  