ghanemar / jquery-datatables-column-filter

Automatically exported from code.google.com/p/jquery-datatables-column-filter
0 stars 0 forks source link

Filter with select on invisible column #150

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create table with at the end invisible but searchable column
2. Use for example { sSelector: "#searchcol3", type: "select"} on this column 
3. This problem is similar to ISSUE 125 or 88

What is the expected output? What do you see instead?
Expected : Table should show result based on this select
Instead : Search is made globally in the table, the search field is fill with 
the option select value. This is because the search is not passed with the 
appropriate column number (take a look at the query string paramater in your 
network). So the wrong values are displayed in the table.

What version of the product are you using? On what operating system?

Ver. 1.5.1.

How to resolve :
1 - Add rel attribut to select based on col number

change this :
var r = '<select class="search_init select_filter"><option value="" 
class="search_init">' + sLabel + '</option>';

to this :
 var r = '<select class="search_init select_filter" rel="'+ i +'"><option value="" class="search_init" >' + sLabel + '</option>';

2 - Let's use this rel attribut 

In function fnCreateColumnSelect() at the end 

change iColumn:
if (bRegex)
oTable.fnFilter($(this).val(), iColumn, bRegex); //Issue 41
 else
oTable.fnFilter(unescape($(this).val()), iColumn); //Issue 25
 fnOnFiltered();
});
if (currentFilter != null && currentFilter != "")//Issue 81
oTable.fnFilter(unescape(currentFilter), iColumn);

to this : 
if (bRegex)
oTable.fnFilter($(this).val(), $(this).attr('rel'), bRegex); //Issue 41
 else
oTable.fnFilter(unescape($(this).val()), $(this).attr('rel')); //Issue 25
 fnOnFiltered();
});
if (currentFilter != null && currentFilter != "")//Issue 81
oTable.fnFilter(unescape(currentFilter), $(this).attr('rel'));

Hope it work for all,
Criticism welcome.

Original issue reported on code.google.com by adrien.f...@gmail.com on 30 Jan 2014 at 5:30