Isn't fnCreatedRow, fnCreatedCell supposed to be called when fnUpdate is called?

Isn't fnCreatedRow, fnCreatedCell supposed to be called when fnUpdate is called?

radisbradisb Posts: 6Questions: 2Answers: 0
edited October 2012 in General
Right now, at least unless I ve messed things up, when I call fnUpdate, only fnRowCallback is called. The problem is that fnRowCallback is called no matter whether a row has been updated or it is just been redrawn and this causes the following problem. If I put complex rendering stuff in fnRowCallback, there is a great performance penalty because this stuff gets called even when not needed (row data not changed). It is needed only in initial table construction and when a row gets updated. And if I put the complex rendering stuff in fnCreatedRow/Cell, everything works fast even with a lot of data and rendering, but I cant rerender just the row that gets updated, because fnCreatedCell/Row doesnt get called in fnUpdate.
Is there a workaround for this? Can I somehow manually call fnCreatedCell/Row ? Any other ideas?
Thanks a lot, Bill

Replies

  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    > Isn't fnCreatedRow, fnCreatedCell supposed to be called when fnUpdate is called?

    No because the row / cell isn't created - it already exists, you are just putting different content into it.

    To be honest I haven't yet resolved how exactly to deal with this situation. Possibly a flag passed to the update method which will tell it to run the created functions or not. At the moment, you need to call the methods manually.

    Allan
  • radisbradisb Posts: 6Questions: 2Answers: 0
    Dear Allan,

    First of all, thanks for the plugin and the commitment.

    I took a look in the code and made a minor change that calls the fnCreatedCell/Row in the fnUpdate function. I just tested it (not thoroughly) and it seems to work. I am afraid to make patch right now, as it is not tested. I just patched fnUpdate to call fnCreatedCell.call() after setting the innerHTML of the cell to _fnGetCellData(.... 'display') and also added _fnCallbackFire( oSettings, 'aoRowCreatedCallback', ...) after the recursive loops end. Also , as you said it could be controlled by a flag. Anyway I will put it in small production system I have full control on, and if it doesnt mess things up, I will try to make a more formal patch or something.

    My opinion on the subject is that I that although the name is fnCreatedCell, its usage begs for being able to be called on data update. I have the impression that the use cases for being called on updates are far more than being called only for creation. ( Maybe it should be renamed to fn(Cell|Row)RenderedCallback() :) . For example see this discussion:

    http://datatables.net/forums/discussion/11554

    which is exactly what I am doing: configuring A LOT of jquery stuff initially, and I want them reconfigured only on data updates, I cant afford to configure them in every time needlessly in fnRowCallback.

    Anyway I ll keep the thread updated on the issues of my change and we shall see.

    Thanks again,
    Bill
This discussion has been closed.