The node function of row.add() API return instance returns null .

The node function of row.add() API return instance returns null .

casuistcasuist Posts: 38Questions: 15Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

1.13.11 version
return node value.

2.0.3 version
return node null
newRow = table.row.add(item);
node = newRow.node() return null.

but!!!
newRow = table.row.add(item).draw();
node = newRow.node() return node value.

I want the node value. But without a draw.

help me.

Answers

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Disable the deferRender option. It is enabled in DataTables 2 and causes the row nodes to be created only when needed by a draw action. Disabling it (deferRender: false) will cause the row node and cells to be created immediately.

    Allan

  • casuistcasuist Posts: 38Questions: 15Answers: 0

    thanks.
    deferRender: false set.
    return tr html.
    but node value is not effect td className.
    older version 1.13.11
    returns className effected value.

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Can you link to a test case showing the issue so I can look into it please?

    Allan

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    Your first code snippet, without draw(), works with DT 2.0.3 in this test case:
    https://live.datatables.net/taxareri/1/edit

    Note deferRender is set false.

    Please provide a link to a test case showing the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • casuistcasuist Posts: 38Questions: 15Answers: 0

    https://live.datatables.net/taxareri/1/edit
    console.log ->
    <tr><td>Tiger Nixon1</td><td>Javascript Developer</td><td>New York</td><td>33</td><td>2012/12/02</td><td>$4,080</td></tr>

    example
    table config
    ...
    comlumns: [
    {
    title: "title",
    data: "colulm1",
    className: "text-end",
    },
    ]
    ...

    after row.add()
    want value =>
    <tr><td class="text-end">some data</td><td>

    but that returns
    <tr><td>some data</td><td>

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794
    edited April 20

    I built a test case for you to show the issue.
    https://live.datatables.net/taxareri/2/edit

    It shows the missing className if the row is not added to the current page. But the row is displayed on the page.

    I also noticed a bit different behavior with DOM sourced table. The added rows aren't displayed on the page. It requires calling draw() to add the rows to the page. The row on the current page displays the className but the row not on the page still does not.
    https://live.datatables.net/taxareri/3/edit

    I added the draw event to both test cases. It seems the ajax loaded test case there is a call to draw() at some point after the rows are added. Not sure what is triggering this draw() call.

    @allan will need to take a look.

    Kevin

  • casuistcasuist Posts: 38Questions: 15Answers: 0
    edited April 21

    Thanks, kthorngren !!!

    https://live.datatables.net/taxareri/2/edit case
    when add current page, it's return wanted value.

Sign In or Register to comment.