Get absolute column index when clicking on it's element even when hidden

Get absolute column index when clicking on it's element even when hidden

krychaj5krychaj5 Posts: 17Questions: 7Answers: 0

Hi!
I have written built-in column filtering plugin for datatables and I have small trouble,

I have created text inputs in each column footer and now - on keyup I want to catch them indexes and then use it when filtering.

I'm getting parent column index by following line in my code:

var visIdx = $(this).parent().index();

It's returning properly index only when ALL columns are visible, but when one of them is hidden, then following columns returning bad indexes.

It causes that when some of columns are hidden filtering is applying to bad columns

Additional - the "searchDelay": 2000, option doesn't work when I'm inputting number in these tfoot inputs..
It's working for main search input but not for them

There is my full code on fiddle: http://live.datatables.net/pulewemu/3/edit?js,console,output

Answers

  • allanallan Posts: 48,464Questions: 1Answers: 7,020 Site admin

    Use column.index() to transform between the visible index and data index.

    Additional - the "searchDelay": 2000, option doesn't work when I'm inputting number in these tfoot inputs..

    Correct. The search delay option is for the built in search options only - not the API methods. You'd need to implement your own throttling for your input elements. Good idea to extend that to the API though, thanks.

    Allan

Sign In or Register to comment.