How to disable search filter from applying to a row

How to disable search filter from applying to a row

westieukwestieuk Posts: 2Questions: 0Answers: 0
edited March 2011 in General
Hi all,

First off, Data tables is the best table jQuery plugin going. I have made a bunch of useful tables :)

However I have encountered a problem I cant seem to resolve myself and was hoping someone might be able to steer me in the right direction?

What I would like to do is DISABLE the search filter input box for particular rows call them "important rows". However I also have buttons and a select which uses the below code... to make things difficult I need these filters to work on these rows, including the "important rows".

[code]$('.keybutton').click(function() {
var keyButtontext = $(this).find('span').text();
Table1.fnFilter(keyButtontext, 0);
} );[/code]

So basically I need to be able to click a button with the string "option 1" and it will filter all rows with "option 1" including "important rows" however if I type in the search filter... it will all rows apart from the "important rows"

Very thankful for any help!

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Interesting one - at the moment in DataTables all rows are treated equally with regard to searching, there is no way to use the built in search and override it from excluding certain rows. However, one option might be to use custom filtering and not the built-in filtering. This is the documentation for that: http://datatables.net/development/filtering and an example: http://datatables.net/examples/plug-ins/range_filtering.html . What you would need to do is take a custom filter input (not the DataTables one, since that would be applied - you want that to be an empty string to use only your custom filtering) and apply the logic to your row (_fnFilter is where it all happens in DataTables if you want to look at any of the matching logic used there).

    Hope this helps!
    Allan
  • westieukwestieuk Posts: 2Questions: 0Answers: 0
    Hi Allan, thanks for your prompt reply.

    I tried as you advised but couldnt get it working. In the end we put the "important rows" into the thead which effectively made them sticky.

    Thanks again..
This discussion has been closed.