fnFilter always off by one column
fnFilter always off by one column
scriderpsd
Posts: 6Questions: 0Answers: 0
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
[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
This discussion has been closed.
Replies
Thanks,
Scott
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(: