fnFilter always off by one column

fnFilter always off by one column

scriderpsdscriderpsd Posts: 6Questions: 0Answers: 0
edited February 2011 in General
I'm using fnFilter as in the API example to search on individual columns. I'm also using server-side processing and pulling the ID field as a hidden column so I can edit rows. My problem is, when I filter via individual column, I'm always off by one column...e.g., as I'm typing information in the third column, the filter is taking place on the second column. I assume this has to do with having the id field as a hidden column. Here is the code I am using for fnFilter.

[code]
$("tfoot input").keyup( function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter( this.value, $("tfoot input").index(this) );
} );
[/code]

It looks like my problem has to do with the second input parameter of fnFilter. Can anyone help me change that so it would be looking one column to the left?

Thanks,

Scott

Replies

  • scriderpsdscriderpsd Posts: 6Questions: 0Answers: 0
    Anyone able to offer an idea on this? I'm still stuck on it 24 hours later!

    Thanks,

    Scott
  • big-dealbig-deal Posts: 38Questions: 0Answers: 0
    I believe you are right - dataTables probably removes the column from the page.
    The result will be that the index returned will be one less than you want.
    just try to write:
    [code]
    $("tfoot input").keyup( function () {
    /* Filter on the column (the index) of this element */
    oTable.fnFilter( this.value, (($("tfoot input").index(this)*1) +1 ));
    } );
    [/code]

    Just make sure that the hidden field will be the first field in the table.
    You can juggle around it if you won't - but it is probably not needed because it will be hidden anyway so it won't realy matter where is it hidden...

    Tell me how it went(:
This discussion has been closed.