Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Is there a faster way to append to tableView than using appendRow or insertRowBefore/After?

I'm doing pagination, when I have a bunch of rows I have to add to the tableView, I use appendRow and/or insertRowAfter. However, they're pretty slow and freezes the UI for a bit.

Is there a better/faster way to append or insertRows into a tableView?

        Contact.findAll({ limit: consts.PER_PAGE, offset: rowsDisplayed - 1, raw: true }, function(rows) {
            var numrows = rows.length;
            for (var i = 0; i < numrows; i++) {
                var row = rows[numrows - 1 - i];
                contactTableView.insertRowAfter(rowsDisplayed - 2, row);
— asked October 22nd 2010 by Wil C
  • iphone
  • tableview

1 Answer

  • If you have a ton of rows to add at once, I believe the recommendation is to update your original data object with them, then take the table object and call


    This will update the table all at once rather than row by row.

    — answered October 22nd 2010 by Mike Robinson
    • How can you get the original data and combine it with the data?

      — commented February 9th 2011 by Léon Doornkamp
    • Godd question…

      — commented July 26th 2011 by Peter Eman Abastillas
    • One approach is to just keep the array around (e.g. as a global) instead of letting it go out of scope. When you want to append rows, use array.push(). When done, use table.setData(array).

      — commented July 26th 2011 by Doug Handy
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.