How can I implement a sorting dropdown for a Responsive jquery footable?

I would like to sort by First name, Job title and DOB using a dropdown (html select) for the following table:
http://fooplugins.com/footable-lite-demos/demo-sorting.htm
Note: Basically what is required the jquery onchange code.
$('#mySelect').on('change', function(){
		//Code goes here.
}
);

Open in new window

LVL 36
Miguel OzSoftware EngineerAsked:
Who is Participating?
 
Julian HansenCommented:
Probably the easiest is to just trigger a click on the column you want to target

$('th:eq(2)')[0].click();

Open in new window

Or
$('th:eq(2)').trigger('click');

Open in new window


There is a hidden column in your table (Last Name) you have to take this into account for the column count.
0
 
Julian HansenCommented:
Do you want to be able to do a sort by multiple columns or do you want to replicate the current column header click for sorting?

The table already sorts on column click - what does the select add?
0
 
Miguel OzSoftware EngineerAuthor Commented:
Just one column (It is dropdown thus only one selection is made) this is an independent sort select when my page goes to mobile view.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Julian HansenCommented:
Ok I am confused. You already have sorting by column by clicking on the column header - what is the rationale for adding a select to do the same thing?
0
 
Miguel OzSoftware EngineerAuthor Commented:
It is a business request for mobile view and it is required. Question could be rephrased as how can I sort at run time using jquery not the UI?  ( Select is just a means to an end)
0
 
Julian HansenCommented:
If you want to be a bit more accurate you can give your <th> a class (say FirstName) and then trigger it on the class
$('th.FirstName')[0].click();

Open in new window

0
 
Miguel OzSoftware EngineerAuthor Commented:
Thanks
0
 
Julian HansenCommented:
You are welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.