Possible Bug using more than 6 individual column filters and server side processing

Possible Bug using more than 6 individual column filters and server side processing

Fredon78Fredon78 Posts: 12Questions: 0Answers: 0
edited August 2012 in Bug reports
We have a table with 7 columns that have individual header filtering. We found out using Firebug that All the input text on the header are correctly linked to their relative sSearch_i sent to the server except for the last column.
Indeed instead of being passed to sSearch_6 the input text of the last column is passed to sSearch.
We did add additional columns and got the same bugs : text in the input filtering header is assigned to sSearch instead of his relative sSearch_i.
So it seems that it bugs when there are more than 6 columns ?!!
Do you have any clue why ?

Replies

  • Fredon78Fredon78 Posts: 12Questions: 0Answers: 0
    For Information below are the variables from Firebug :
    [quote]
    _ 1343806842003
    bRegex false
    bRegex_0 false
    bRegex_1 false
    bRegex_2 false
    bRegex_3 false
    bRegex_4 false
    bRegex_5 false
    bRegex_6 false
    bSearchable_0 true
    bSearchable_1 true
    bSearchable_2 true
    bSearchable_3 true
    bSearchable_4 true
    bSearchable_5 true
    bSearchable_6 true
    bSortable_0 true
    bSortable_1 false
    bSortable_2 false
    bSortable_3 false
    bSortable_4 false
    bSortable_5 false
    bSortable_6 false
    iColumns 7
    iDisplayLength 200
    iDisplayStart 0
    iSortCol_0 0
    iSortingCols 1
    mDataProp_0 0
    mDataProp_1 1
    mDataProp_2 2
    mDataProp_3 3
    mDataProp_4 4
    mDataProp_5 5
    mDataProp_6 6
    patientid 6
    sColumns
    sEcho 29
    sRangeSeparator ~
    sSearch 17
    sSearch_0
    sSearch_1
    sSearch_2
    sSearch_3
    sSearch_4
    sSearch_5
    sSearch_6
    sSortDir_0 asc
    [/quote]
  • allanallan Posts: 61,920Questions: 1Answers: 10,151 Site admin
    I'm going to guess that you have a hidden column and haven't taken that into account when using fnFilter - but without more information I can't say. Ideally if you can give us a link, or at least run your table through the DataTables debugger.

    Allan
  • Fredon78Fredon78 Posts: 12Questions: 0Answers: 0
    Hi Allan,

    Thanks for your suggestions.
    Actually using the DataTables debugger we find out something strange/interesting.
    Indeed we are using two tables on the same html page which use the serve-side approach.

    The first one has 6 columns and the second one has 7 columns and it seems that even if these tables have different id (#) the number of column of the first table has a repercution on the second table.

    The first table has 6 column and then the 7th column of the second table is not taken into account.
    And when we switch the order of the table in the html code the 7 columns of the buggy table are working fine.

    Do you have any idea on how to avoid that the number of column of the first datatable in the html code has an impact on the following ones.

    Fred
  • allanallan Posts: 61,920Questions: 1Answers: 10,151 Site admin
    Each table should be treated entirely independently and should have no effect on the other. I would need to see an example of the mix, as I've used multiple server-side tables my many projects myself and not yet seen this issue. If you can give me a link that would allow me to see what is going on and why.

    > even if these tables have different id (#)

    Its worth pointing out here that IDs _must_ be unique. That is a requirement of HTML. Two elements cannot share the same ID in the same document as that would create invalid HTML. DataTables expects the HTML to be valid, so it might be worth running your page through the W3C HTML validator.

    Allan
  • Fredon78Fredon78 Posts: 12Questions: 0Answers: 0
    Hi Allan,

    Thanks again for the rapidity of your reply. Thanks to my colleague Ilyass we fixed the bug in two steps. Here is how.


    Step 1.
    Ilyass did modify the file : jquery.dataTables.columnFilter.js Version: 1.4.8 by adding the line
    var oTable = $(this) where other variables are initialized.
    [code]
    (function ($) {
    $.fn.columnFilter = function (options) {
    var asInitVals, i, label, th;
    //var sTableId = "table";
    var sRangeFormat = "From {from} to {to}";
    //Array of the functions that will override sSearch_ parameters
    var afnSearch_ = new Array();
    var aiCustomSearch_Indexes = new Array();
    var oFunctionTimeout = null;
    var fnOnFiltered = function () { };
    var oTable = $(this);

    function _fnGetColumnValues(oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty) {
    [/code]

    Indeed it seems that without doing that some parameters related to the second table like the column indexation were affecting the first table especially when the number of column in the second table is lower than in the first one.
    So this line fixed the Bug.


    Step 2.
    This morning I was writing you back and when I check the code I found out that around line 470 there was the declaration oTable = this;
    And by deleting Ilyass line and just modify "oTable = this" by "var oTable = this" it fixed the bug.
    I guess the fact that var was missing had a buggy repercution on the Column filter with server side.
    May be adding var modify the scope of oTable.

    So our suggestion would be to replace oTable = this by var oTable = this in the column filter file.


    One last comment :
    It is very strange that on the webpage dedicated to column filter download it is the version 0.9 that is available.
    http://code.google.com/p/jquery-datatables-column-filter/downloads/list

    So to make the column filter located in the header working we had to download the version 1.8 available on this demo page.
    http://jquery-datatables-column-filter.googlecode.com/svn/trunk/index.html

    I mentionned that in case someone get the same problem we got to make it working on the header.

    Thanks,

    Fred
  • allanallan Posts: 61,920Questions: 1Answers: 10,151 Site admin
    Hi Fred,

    Thanks for the update. Good to hear you got it working!

    The column filter plug-in is third party, so I don't have any way of updating the downloads there. Perhaps worth opening an issue in Google Code?

    Allan
This discussion has been closed.