where to put .button() call

where to put .button() call

grahampcharlesgrahampcharles Posts: 20Questions: 1Answers: 0
edited February 2013 in DataTables 1.9
When using a jQueryUI button in a datatable, it seems that either of these works:

[code]
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$(nRow).find(".the-button").button({ icons: { primary: "ui-icon-cart"} });
return nRow;
}
[/code]

or

[code]
"fnDrawCallback": function( oSettings ) {
$(".the-button").button({ icons: { primary: "ui-icon-cart"} });
}
[/code]

Is one preferred to the other? Am I going to run into problems with these approaches?

Thanks,

g.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Row callback happens every time the row is displayed, so that can impact performance. Likewise the draw callback happens every draw. Unless you are adding and removing rows dynamically I'd suggest doing it in fnInitComplete . If you are adding and removing rows, then perhaps consider using fnCreatedRow which fires only once for each row.

    Allan
  • grahampcharlesgrahampcharles Posts: 20Questions: 1Answers: 0
    I'm not adding rows dynamically but the data is retrieved from a server, so every filter, sort, or paging operation triggers a redraw. Since that's the case, I guess you're suggesting fnCreatedRow. I'll give that a shot.
This discussion has been closed.