Tableview without a tabGroup = no rows! (bug)
If I create a tableview in a window that isn't assigned to a tabGroup, it no longer displays the rows in 1.4. Adding the window to the tabGroup causes the rows to show up again.
Sample code:
app.js
newWindow.js
When you run the app, you'll see the tableview header but not the row/text. If you uncomment the last lines in app.js, so that the new window is part of the tabGroup, the row/text will then show up.
Could someone else please confirm this? Any thoughts on a work-around that doesn't involve adding the new window to a tabGroup?
9 Answers
-
Yeah, it's doing this.
Populate the table on the open event of the window the table belongs to, with setData.
-
Thanks for the confirmation, Tamas. However, I tried adding the following code to the bottom of my newWindow.js, as you suggested, and it doesn't seem to make a difference:
Ti.UI.currentWindow.addEventListener('open', function(e) { tableview.setData(data); });
Is that what you had in mind?
-
Yeah, only that don't use Ti.UI.currentWindow, but a declared variable
var the_win = Tianium.UI.createWindow( the window that holds the table ) the_win.addEvent('open', ....)
Also use Titanium, not Ti, sometimes Ti it's lost in the scope of some functions( donno why )
-
Hmmm…that still doesn't seem to change anything for me. Here's the updated app.js that I'm using (newWindow.js is empty now):
app.jsNot being able to use UI.currentWindow makes the code really awkward, because that forces me to define the event listener in the file that creates the window, rather than the file that creates the tableview. Regardless, I'd still like to see if I can get your idea to work.
-
Does anyone else have any thoughts on a work-around for this?
-
Bump..
-
Just confirmed this behavior and filed a bug report in Lighthouse. Not sure why creating custom grouped view sections is not working in a standalone window. Possible near term solutions would be to use standard view components to achieve the same effect, or use standard table row attributes for the grouped view (which does work in a standalone window), as in:
var data = []; var section = Ti.UI.createTableViewSection({ headerTitle:'A section header' }); data[0] = section; section.add(Ti.UI.createTableViewRow({hasChild:true,title:'Row 1'})); section.add(Ti.UI.createTableViewRow({hasDetail:true,title:'Row 2'})); section.add(Ti.UI.createTableViewRow({hasCheck:true,title:'Row 3'})); section.add(Ti.UI.createTableViewRow({title:'Row 4'})); // create table view var tableview = Titanium.UI.createTableView({ data:data, style:Titanium.UI.iPhone.TableViewStyle.GROUPED, }); // create table view event listener tableview.addEventListener('click', function(e) { // event data var index = e.index; var section = e.section; var row = e.row; var rowdata = e.rowData; Titanium.UI.createAlertDialog({title:'Table View',message:'row ' + row + ' index ' + index + ' section ' + section + ' row data ' + rowdata}).show(); }); // add table view to the window Titanium.UI.currentWindow.add(tableview);
-
On further investigation, from what I can tell, this isn't actually a problem with GROUPED table styles. It is when you use TableViewRow's (vs. just a generic object with a title/attributes) in the table. I can have a table that uses the GROUPED style, and has data such as [{title: "hello"}] and that works fine, but as soon as I create a row with createTableViewRow, add a field to it, and add it to the table, then it doesn't work.
-
This bug is really obnoxious in my case, as my entire app uses a grouped table view display for consistency, but I also need a login page that's not part of the tab group. I can't keep the look of my app consistent and I have to do all kinds of ridiculous shenanigans in the code to work around the problem. Kevin created this bug in Lighthouse months ago, but it's marked as low priority and isn't even being considered for 1.5. If anyone else is affected by this problem, please "watch" the bug in Lighthouse and add your comments there. Maybe someone will finally notice and decide to fix it.