need to get column index when column title is known
need to get column index when column title is known
umaeswara
Posts: 83Questions: 16Answers: 0
in DataTables
http://live.datatables.net/toxanume/5/edit here is my testcase.
i want to know the index of the column Position; and can you please advice how can I do that.
I used jquery way of doing it but it is taking long time. so i want to use datatable apis.
thanks
Uma-
This question has accepted answers - jump to:
Answers
You are getting this error:
You need to wrap
table.column( i ).header()
into jQuery to get the text, like this:Updated example:
http://live.datatables.net/gigerava/1/edit
Another option is to use
columns.name
then use thecolumn-selector
of{string}:name
to get the index. I added this to the example.Kevin
perfect i was trying position:name method too earlier. i have copy pasted your line in my testcase and it is not working. i am so sorry but i couldnt figure out what is wrong with that line. console.log('Using Position:name', table.column("Position:name").index()); my testcase http://live.datatables.net/toxanume/5/edit
You didn't add the
columns.name
option in your Datatables init code.Kevin
Hi kevin,
i have 60 columns, can I use any render function to initiate columns.name ? like get the name of the column, and init name for each of the columns.
thanks,
Uma-
You have to define
columns.name
a initialization. You can create a variable that contains yourcolumns
definition before initialization then use that variable in the init code, for example:http://live.datatables.net/gigerava/3/edit
Kevin