Mistake in API ?

Mistake in API ?

mathieufanneemathieufannee Posts: 17Questions: 0Answers: 0
edited September 2012 in DataTables 1.9
Hello Allan,

thanks for your great work: I use DataTables every day now!

I had a small remark:
when checking the API, I found that fnGetPosition says that "if given as a cell (as an argument), an array of [row index, column index (visible)] is given".

But if I am right, the returned array is [row index, column index (visible), column index], meaning the last value is the true index of the column (taking invisible columns into account).
Or is it discouraged to use the last value?

Mathieu

Replies

  • allanallan Posts: 63,395Questions: 1Answers: 10,451 Site admin
    Yes you are absolutely correct - the should be a three index return.

    I've just pushed up a fix for this and the documentation on this site will be updated when I publish 1.9.4: https://github.com/DataTables/DataTables/commit/66e92ab655d3ca45214d3115254981f5f99a73d0

    I would say that although use of the last index isn't specifically discouraged, but rather use of fnGetPosition is! What are you using it for? Although it won't be removed, I am actively trying to discourage its used.

    Allan
  • mathieufanneemathieufannee Posts: 17Questions: 0Answers: 0
    You're asking what I am using fnGetPosition() for?

    For example, I'm using it in an UNDO-function:
    when some cell content is changed by some user (with jEditable), I put the old content and cell position (X,Y) onto a stack. When the user clicks on 'Undo', the top of the stack is read ( [oldContent, x, y] ) so I can address the right position in the table to restore the content: fnUpdate( oldContent, y, x, false )

    How would you do that without using fnGetPosition() ?
  • allanallan Posts: 63,395Questions: 1Answers: 10,451 Site admin
    Hum :-(. Good point. I had thought I had updated fnUpdate to allow a cell to be passed in and it would resolve automatically. That is something that the API updates in 1.10 is going to made much easier... So yes, I guess fnGetPosition is the way to do this at the moment...

    Allan
This discussion has been closed.