Thursday, March 28, 2013

Titanium TableView row count


How to get the number of rows in tableview with Titanium?
TableView default has one section. "table.data" is the section array.
If you don't create section, your rows are in "section 0".
Get the row count by

table.data[0].rows.length;

or

table.data[0].rowCount;




situee's blog

if you have more than one section.
you can iterate the sections:


var sections = theTable.data;
for(var i = 0; i < sections.length; i++){
    var section = sections[i];
    for(var j = 0; j < section.rowCount; j++){
        var row = section.rows[j];
        Ti.API.debug(JSON.stringify(row));
    }
}


Reference:
http://developer.appcelerator.com/question/117594/number-of-rows-in-table

No comments:

Post a Comment