HTML table sorting
P粉752479467
2023-08-27 15:36:19
<p>So basically I'm running a mysql query that fetches data from my database and displays it in an easy-to-read layout for the user. </p>
<pre class="brush:php;toolbar:false;">Name-----Address----Sales Person</pre>
<p>You get the gist. Now I want the user to sort the html table by salesperson. How can I easily do this using a dropdown menu? </p>
<p><br /></p>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class='menu'>
<ul>
<li><a href='#'><span>Sales Person</span></a>
<ul>
<li><a href='#'><span>Melissa</span></a></li>
<li><a href='#'><span>Justin</span></a></li>
<li><a href='#'><span>Judy</span></a></li>
<li><a href='#'><span>Skipper</span></a></li>
<li><a href='#'><span>Alex</span></a></li>
</ul>
</li>
</ul>
</div></code></pre>
<p><br /></p>
This is another library.
The changes that need to be made are -
Add sorting js
Add the class name
sortable
to the table.Click on the table title to sort the table accordingly:
Check if you can use any of the JQuery plugins mentioned below. Simply fantastic, offers a wide range of working options and is less effort to integrate. :)
https://github.com/paulopmx/Flexigrid - Flexgrid
http://datatables.net/index - Data table.
https://github.com/tonytomov/jqGrid
If not, you need to have a link to the headers that call the server-side script to invoke the sort.