row().data() seems to trigger partial update/draw

row().data() seems to trigger partial update/draw

redfellowredfellow Posts: 13Questions: 6Answers: 0
edited January 2023 in Free community support

Using something like row.data({0: "New Name"}); seems to update the row in the table despite not calling .draw() explicitly. Is there a way around this? When not calling draw it updates the row but without triggering the cells (custom) render function. I want to manipulate the data and then draw all the changes at once.

I was attempting to create a test case at http://live.datatables.net/gikumabo/1/edit but the website is telling me "too many redirects" all of a sudden.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    Are you saying you want to update the table data without updating the table's display until you call draw()? I don't believe Datatables has an option for this.

    Please describe the problem you are trying to solve.

    Kevin

  • redfellowredfellow Posts: 13Questions: 6Answers: 0
    edited January 2023

    That's exactly what I thought was possible. The last example here looked like it would be just that: https://datatables.net/reference/api/row().data()

    In my case, one of the custom formatters is adding an <img> in a TD and I want to refrain from re-drawing the row until all data is updated. I can change my internal function to keep the data object at hand until I'm ready to draw so it's non-issue, but the documentation led me to believe I could update the data and postpone the draw.

    When I update the data, the <td> suddenly contains the URL to the image. Only when I call draw() is the formatter applied and it turns to <img>.

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    Answer ✓

    This is from the row().data() docs:

    Note that when used as a setter, this method sets the data to apply to the table, but does not update the table's internal caches of data until the draw() method is called.

    The first part indicates that the HTML table will updated. The Datatables cache is what keeps track of sorting, searching and paging. This is updated once draw() is called and the HTML table will reflect the data cache sorting, searching and paging.

    I can change my internal function to keep the data object at hand until I'm ready to draw

    Sounds like a good solution.

    Kevin

Sign In or Register to comment.