Getting column index from sName

Getting column index from sName

jcm112388jcm112388 Posts: 2Questions: 0Answers: 0
edited November 2012 in General
Is there an easy way to get the index of a column from the sName of that column?

Something like:
[code]
var oTable = $('#example').dataTable();
var iColIndex = oTable.fnColIndex("exampleColumn");

alert( "Index of column with sName: exampleColumn is: " + iColIndex );
[/code]

Right now I'm looping through aoColumns looking for the sName that I need which isn't very efficient to do for every time I need the column index. I know I can just create my own array with that data in it but just wondering if there is something already like that.

Thanks in advance!

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Currently no, I'm afraid not. This will change with v1.10 of DataTables when sName will become an important player, but at the moment sName is seriously under utilised in DataTables and the way you've done it is about as good as it gets...

    Allan
  • jcm112388jcm112388 Posts: 2Questions: 0Answers: 0
    Thanks for confirming Allan. I ended up just looping through aoColumns building the array I needed the first time I needed the data. Then referencing that array if I needed it again later.

    Do you have any idea when v1.10 might be released?

    Thanks again for the response Allan.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    edited November 2012
    > Do you have any idea when v1.10 might be released?

    Likely January of February. I had hoped for a beta before the new year, but that is looking unlikely with the amount of work piling up at the moment unfortunately. A lot of the work I want to do for 1.10 has actually been done already - the new API is the tick ticket number still to be done... (oh - and redo this web-site :-) ).

    Allan
This discussion has been closed.