fnGetPosition undefined

fnGetPosition undefined

BigPoppaGBigPoppaG Posts: 4Questions: 1Answers: 0

http://live.datatables.net/vasikox/1/edit
Hi there
Firstly thanks for the amazing tool. All working great even for a novice - except I'm totally stumped here:
Hopefully the datatables live link shows what's going on.
The console log shows the fnGetPosition is undefined.
Can anyone help fix this example.
I'm trying to read the (hidden) id field a datatable based on the clicked cell.
Any help much appreciated.
Thanks.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Second FAQ :-).

    Use $().dataTable() (lowercase d) if you want to use the old style API methods (I'd recommend you to use the new style API if possible).

    Allan

  • BigPoppaGBigPoppaG Posts: 4Questions: 1Answers: 0

    Thanks for the really quick reply.
    So what is the new style way of looking up the underlying data for the row of a given cell?
    Sorry if I'm asking another FAQ.

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    cell().data(). The new API is introduced in the manual and has an overview. Would be interested to know what you think of it.

    Allan

  • BigPoppaGBigPoppaG Posts: 4Questions: 1Answers: 0

    Thanks again Allan. So I can do $(this).data() where this is my clicked td and that gives the data for the whole row? Sorry if I'm still confused. A concrete example would be really helpful. Otherwise I'll give it another go when I'm back coding!

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    $(this).data()

    No, you can use the cell().data() method. For example: table.row( this ).data().

    If you want it for the whole row, you would use row().data(). For a column use column().data(). Keep in mind that each of the selector methods have their own selector types as well. The documentation for each covers them in detail.

    Allan

  • BigPoppaGBigPoppaG Posts: 4Questions: 1Answers: 0

    Fantastic. That gives me the data given the row. But how do I get the row given the cell? What's the new style version of fnGetPosition? Can I do cell().row()? Last question, honest!

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    edited June 2014 Answer ✓

    But how do I get the row given the cell?

    table.row( this.parentNode ).data()
    

    where this is a cell.

    Allan

This discussion has been closed.