(Android) Tableview: updateRow with headers
Hi,
I'm not sure if this is a known bug, but: when I try to update a row of a table view using the code below I get an out of bounds error, but its fine if I take the headers out of the table. Is this my error or a bug?
Cheers,
Mark.
var LogFind = Ti.UI.createTableView({
data: [
{ header: 'Details', title: 'Tag', hasChild: true, color: 'black', url: 'LogFind/LogFind.js' },
{ title: 'Comment', hasChild:true, color: 'black', url: 'LogFind/LogFind.js' },
{ header: 'Images', title: 'Picture 1', hasChild:true, color: 'black', url: 'LogFind/LogFind.js' },
{ title: 'Picture 2', hasChild: true, color: 'black', url: 'LogFind/LogFind.js' },
{ title: 'Picture 3', hasChild: true, color: 'black', url: 'LogFind/LogFind.js' },
{ header: 'Commands', title: 'GPS', color: 'black', url: 'LogFind/LogFind.js' },
{ title: 'Submit', hasChild: true, color: 'black', url: 'LogFind/LogFind.js' }
]
})
LogFind.addEventListener ('click', function(e) {
alert((e.index))
})
var win = Titanium.UI.createWindow ({
backgroundColor: Globals.backgroundColor
});
win.add(LogFind);
win.open();
LogFind.updateRow(5, { title: 'Getting GPS...' });
14 Answers
-
Yeah, weak sauce guys… Let's fix this…
-
i'm not exactly sure, but isn't the row index based on zero?
-
Hiya,
Still got the problem - even when using 'name' and 'getIndexByName'. The getIndex is returning the appropriate index, but then the updateRow fails if the headers are there.
Mark.
-
I've opened Ticket 697 for this issue. You should set a watch on the ticket to receive updates.
-
Wow, Ticket 697 is still an open bug. I'm having a problem with updates and tableview and wonder how stable this is. Cost me more than 2 days so far. Any updates on this?
-
Does anyone know of a workaround for this? I'm having the same problem and it looks like ticket 697 is still open.
-
The bug still persists! =(
-
So, the bug is still there… any workaround?
-
When A YEAR passed by and nothing got done.
The bug is still there…..
Oh god, I don't ask for more features, but only bugs get fixed… please.
-
Don't know about android, but I've had troubles with accessing rows in the table on iphone when having headers. The problem is in
data[0].row[row_index]
when you have headers you nead to do something likedata[group_index].row[row_index_within_that_group]
-
25
-
very easy, the position isn't exists, you should use without header…
-
The use of a header attribute when creating a row is syntactic sugar for creating a section then adding rows to that section. Once the TableView is created from this declarative style, the rows are available programmatically as:
table.sections[i].rows[j]
The 3 header attrs in the OP data will create 3 sections. Each additional row is appended to the previous section until a new header attr is encountered.
I'm not sure if this bug is closed or not, the link is inaccessible. There's a lot of confusion in these answers and I think it largely stems from this understanding. Incidentally, the Titanium.UI.ListView contains it's runtime data in a similar way: list.sections[i].items[j]
-
Well, the problem is with the index you're passing to
updateRow
, but I can't figure out why it's a problem.It's interesting that it works when you remove the headers. There seems to be a variety of issues relating to headers at the moment.
You should be able to get around it by adding a
name
to the row:{ name:'gps', header: 'Commands', title: 'GPS', color: 'black', url: 'LogFind/LogFind.js' }
Then call:
LogFind.updateRow(LogFind.getIndexByName('gps'), { title: 'Getting GPS...' });