fnColumnIndexToVisible - Cannot read property 'nTr' of undefined

fnColumnIndexToVisible - Cannot read property 'nTr' of undefined

mellamokbmellamokb Posts: 4Questions: 0Answers: 0
edited November 2013 in DataTables 1.8
I'm trying to use the plugin method "fnColumnIndexToVisible". When I call it directly, for example to get row 0, column 3:

payTypeTable.fnColumnIndexToVisible(payTypeTable.fnSettings(), 0, 3)

I get the following error: TypeError: Cannot read property 'nTr' of undefined

However, if I manually access the extension Api and call the method, it works fine:

payTypeTable.dataTableExt.oApi.fnColumnIndexToVisible(payTypeTable.fnSettings(), 0, 3)

What would cause this behavior?

(Also, it is called "fnGetTd" in the actual code, is that supposed to match the name?)

Replies

  • mellamokbmellamokb Posts: 4Questions: 0Answers: 0
    Erm, I think I figured out my issue. I guess the first parameter is not supposed to be supplied manually, that's the "caller" like a c# extension method. I left out the first parameter in my original call and it works now :)
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Yup - bob on. As noted at the top of the plug-ins page:

    > Please note that DataTables will automatically pass the settings object as the first parameter. As such, you do not need to pass the settings object, which you will see if you look at the plug-in API's code.

    I freely admit this is crap. The new API in 1.10 will be much more obvious (indeed, this function you are using will be built in - `column.index()` to translate to and from the visible index.

    Allan
This discussion has been closed.