Setting data() results in a draw() - v1.10

Setting data() results in a draw() - v1.10

billmbillm Posts: 3Questions: 1Answers: 0

The API reference states that when data() is "used as a setter, this method sets the data to apply to the table, but does not visually update the tables display to account for this new data. In order to have the table's display updated, use the draw()DT method."

However, when I set data without calling draw() the table draws anyway?

Anyone else noticed this? Is it a bug or am I doing something wrong? I want to set data but I don't want to update the view until later.

http://jsfiddle.net/CZpWZ/6/

Answers

  • billmbillm Posts: 3Questions: 1Answers: 0

    This is for v1.10

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    I think I need to clarify the documentation there - the HTML will be updated (i.e. the innerHTML content is written to immediately, thus the appearance is updated - however, the sorting and filtering applied to the table is not updated until draw() is called.

    Allan

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Documentation will now say:

    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. This can be done simply as a chained method of the row().data() method's returned object - for example table.row( 0 ).data( newData ).draw();. This is done to allow easy optimisation of the table where successive updates can be applied before the table is redrawn.

    I've not deployed the change yet - but will soon!

    Thanks for flagging this up.

    Allan

  • billmbillm Posts: 3Questions: 1Answers: 0

    No problem. Thanks for the clarification!

    Bill

This discussion has been closed.