fnGetPosition is not a function

fnGetPosition is not a function

badbytebadbyte Posts: 33Questions: 7Answers: 0

Now, I know that there is already a thread covring that topic but:
1. In the thread xrcr9709 mentioned that the row object needs to be a DOM object? This is maybe something that I came in conact with but unconciously.
2. I looked up the documentation of DataTables copied 1:1 the example code, where I have made some minor adjustments so that the code is pointed to my dataTable. Yet I get that error message.

Here is my code that I have currently embeeded:

    $('#ruleTable tbody td').click(function () {
        // Get the position of the current data from the node
        var aPos = ruleListTable.dataTable().fnGetPosition(this);

        // Get the data array for this row
        var aData = ruleListTable.fnGetData(aPos[0]);

        // Update the data array and return the value
        aData[aPos[1]] = 'clicked';
        this.innerHTML = 'clicked';
    });

Maybe someone could point out the mistake that I'm not seeing.

Thx in advance.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin
    Answer ✓

    That's the old API. It should actually work, but I'd suggest using this instead:

    var table = $(...).DataTable(...); // NOTE the capital D
    
    $('#ruleTable tbody td').click(function () {
      table.cell( this ).data( 'clicked' );
    });
    

    Running example: http://live.datatables.net/kizasize/1/edit .

    Allan

  • badbytebadbyte Posts: 33Questions: 7Answers: 0

    I tried that, and got the following error message:
    Uncaught TypeError: table.cell is not a function

  • kthorngrenkthorngren Posts: 20,139Questions: 26Answers: 4,734

    Without seeing your code in action it would be hard to say. Please post a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Just to make sure you saw Allan's comment (// NOTE the capital D) please see this FAQ.

    Kevin

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin

    Agreed - did you see the NOTE comment? The example I linked to is working, so as Kevin says, we'd need an example showing it not working to be of much more help.

    Allan

This discussion has been closed.