farizluqman / jquery-datatables-column-filter

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

Server Side incompatibility with number and date ranges #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Setup ColumnFilter with number rangers
2. Use DataTables server side functionality
3. Filtering does not function

What is the expected output?
Functioning filters

What do you see instead?
Broken filters. The server side script receives "undefined~undefined" for all 
ranges regardless of entered values.
One of the sources of the problem can be observed by viewing this line:
                    return $("#range_from_" + index).val() + properties.sRangeSeparator + $("#range_to_" + index).val()
In unpatched 1.2.1 that corresponds to line 308.
Reviewing the rendered HTML that should be looking for something more along the 
lines of:
                    return $("#"+oTable.attr("id")+"_range_from_" + index).val() + properties.sRangeSeparator + $("#"+oTable.attr("id")+"_range_to_" + index).val();

Basically ColumnFilter renders the field with the ID prepended but then refers 
to it without when using Server Side. Beyond that for multiple ranges they all 
render with the same index. I am digging further but it appears that because of 
how the fnSearch_ function is pushed on unevaluated when they run they all run 
with the last index.

What version of the product are you using? On what operating system?
Version 1.2.1 from trunk

Original issue reported on code.google.com by g.duerrm...@gmail.com on 1 Aug 2011 at 12:50

GoogleCodeExporter commented 9 years ago
My apologies it looks like the beginning portion of this, regarding the lack of 
table ID, was already reported in Issue 9
The second portion of this I am still unable to solve. If I have 3 number 
ranges, and put as value 1, 2, 3 as the From value in each of the ranges, the 
server sees:
3~undefined
3~undefined
3~undefined

Whatever is in the last range is used for all of the ranges.

Original comment by g.duerrm...@gmail.com on 1 Aug 2011 at 1:03

GoogleCodeExporter commented 9 years ago
I have come up with a solution, however it requires eval(). If someone can 
avoid eval() for this please let me know, I would much prefer to not use eval() 
but I am all out of ideas.

The updated section now looks like this:
            for (j = 0; j < aiCustomSearch_Indexes.length; j++) {
                var index = aiCustomSearch_Indexes[j];
                eval("var fnSearch_ = function () { return $(\"#"+oTable.attr('id')+"_range_from_"+index+"\").val()+properties.sRangeSeparator+$(\"#"+oTable.attr('id')+"_range_to_"+index+"\").val(); }");
                afnSearch_.push(fnSearch_);
            }

Basically replacing line 308 of an unpatched 1.2.1 with the above eval line 
will solve the following problems:
- ColumnFilter does not work with number or date ranges due to an invalid field 
reference. Fields are created with table ID but later not referenced in the 
same way.
- ColumnFilter does not work with multiple number or date ranges due to the 
creation of dynamic variable functions. Only the last values referenced in the 
function applies to all fields.

Thanks everyone!

Original comment by g.duerrm...@gmail.com on 1 Aug 2011 at 4:15

GoogleCodeExporter commented 9 years ago
It didn't take long for someone to come up with a better solution than that! In 
Issue 9 Comment 2 ( 
http://code.google.com/p/jquery-datatables-column-filter/issues/detail?id=9#c2 
) The op gives a proper solution, fixing both of these problems in diff format 
against vanilla 1.2.1

Original comment by g.duerrm...@gmail.com on 1 Aug 2011 at 5:36

GoogleCodeExporter commented 9 years ago
Hi,

Could you please try it again with verison 1.2.3?

Thanks,
Jovan

Original comment by joc...@gmail.com on 24 Sep 2011 at 11:27

GoogleCodeExporter commented 9 years ago
Please reopen issue if this is not fixed after you try it.

Thanks,
Jovan

Original comment by joc...@gmail.com on 25 Sep 2011 at 6:59