how to get filter search box input?

how to get filter search box input?

attatt Posts: 1Questions: 1Answers: 0

Hi,

I have a question concerning the filter search text input. My goal is to build a table and use the filter provided by dataTables. It works fine and I would like to thank all the developers and authors. Your work helped me tremendously.

My next step is to retrieve the filtered rows and pass the values from the filtered results on to another flash tool. By filtered results I mean the narrowed result list I get when I type in search terms into the search box in the upper right corner. I have browsed the discussion board and have found some very useful hints. I used

oTable.fnFilter('searchbox_input');
var data = oTable._('tr', {"filter": "applied"});

to set a filter and identify the filtered rows.

But now I got a little stuck as fnFilter uses a set filter value and not the dynamic text from the search box input.
One discussion suggests to use

$('div.dataTables_filter input').val()
OR
oTable.fnFilter(oInput.sSearch);

to get the input text of the searchbox.

I followed the discussions and tried to write these code:

$(document).ready(function() {

var oTable = $('#example').dataTable();
var data = $('div.dataTables_filter input').val();
alert (data);

});

$(document).ready(function() {

var oTable = $('#example').dataTable();
// Filter to 'Webkit' and get all data for
//oTable.fnFilter('Webkit');
oTable.fnFilter(oInput.sSearch);
var data = oTable._('tr', {"filter": "applied"});

// Do something with the data
alert( data.length+" rows matched the filter" );

});

Neither of it returns the search box input nor the number of rows in the narrowed result list. Do you know how I could solve this?

Furthermore, I wondered how do I set up my code in this post so that it has the line numbers and scroll bars as other people have it in their posts?

Thanks in advance.

Regards,

Anh Thu

This discussion has been closed.