Titanium TableViewRow classname with custom rows
- by pancake
I would like to know in what way the 'className' property of a Ti.UI.TableViewRow helps when creating custom rows.
For example, I populate a tableview with custom rows in the following way:
function populateTableView(tableView, data) {
var rows = [];
var row;
var title, image;
var i;
for (i = 0; i < data.length; i++) {
title = Ti.UI.createLabel({
text : data[i].title,
width : 100,
height: 30,
top: 5,
left: 25
});
image = Ti.UI.createImage({
image : 'some_image.png',
width: 30,
height: 30,
top: 5,
left: 5
});
/* and, like, 5+ more views or whatever */
row = Ti.UI.createTableViewRow();
row.add(titleLabel);
row.add(image);
rows.push(row);
}
tableView.setData(rows);
}
Of course, this example of a "custom" row is easily created using the standard title and image properties of the TableViewRow, but that isn't the point. How is the allocation of new labels, image views and other child views of a table view prevented in favour of their reuse? I know in iOS this is achieved by using the method -[UITableView dequeueReusableCellWithIdentifier:] to fetch a row object from a 'reservoir' (so 'className' is 'identifier' here) that isn't currently being used for displaying data, but already has the needed child views laid out correctly in it, thus only requiring to update the data contained within (text, image data, etc).
As this system is so unbelievably simple, I have a lot of trouble believing the method employed by the Titanium API does not support this.
After reading through the API and searching the web, I do however suspect this is the case. The 'className' property is recommended as an easy way to make table views more efficient in Titanium, but its relation to custom table view rows is not explained in any way. If anyone could clarify this matter for me, I would be very grateful.