Data Tables API additional Drop down box

Data Tables API additional Drop down box

jamesjw007jamesjw007 Posts: 35Questions: 0Answers: 0
edited June 2012 in General
In your dynamic table you have a drop down box that lets you sort your entries by a specific number (10,25,50,100) and it will display that many records per page.

Is it possible to add another drop down directly to the right of that and have it sort on something else in the table? I looked through the API and saw how to add additional sort boxes/dropdowns but nothing directly to the right of the previous one.

Is this something that is easy to duplicate?

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Sure you can do that - there isn't a built in option that you can just toggle to do it - but using the fnSort API method all you need to do is construct a SELECT list and have it call fnSort with the information you want, telling it how to sort the table.

    This blog posts details how feature plug-ins can be created: http://datatables.net/blog/Creating_feature_plug-ins

    Allan
  • jamesjw007jamesjw007 Posts: 35Questions: 0Answers: 0
    Hi Allan,

    Thanks for posting a response. I looked over the forum post and understand it some. What I am most confused about is where I put this code. Do I just make a seperate javascript file and it will just know to fit into this tool?
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    edited June 2012
    Put it somewhere before your DataTables initialisation, but after you include DataTables in your HTML. You can put it in a separate file if you wish, but that isn't required.

    Allan
This discussion has been closed.