[TIMOB-15278] iOS: ListView with custom Template in navigationWindow - listItems not rendered after push/pop
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2013-09-19T22:05:49.000+0000 |
| Affected Version/s | Release 3.1.0, Release 3.1.1, Release 3.1.2, Release 3.1.3 |
| Fix Version/s | 2013 Sprint 19, 2013 Sprint 19 API, Release 3.1.4, Release 3.2.0 |
| Components | iOS |
| Labels | 3.1.3, 3.2.0, ios, ios7, listitem, listsection, listview, navigationWindow |
| Reporter | Vincent |
| Assignee | Vishal Duggal |
| Created | 2013-09-17T16:01:15.000+0000 |
| Updated | 2013-10-18T21:58:55.000+0000 |
Description
After setting a ListView with custom template in a navigation window, the listItems are correctly displayed first time. Go back to first window and try to display again the ListView : listItems are not displayed/rendered.
With a builtin Template there is no problem, listItems are displayed at all times.
See below for test cases.
TEST CASE with a custom template: click on 'dataset' to display the listView in the second window. Go Back click again on dataset RESULT: no more listItems displayed.
detailTemplate = { childTemplates: [ { type: 'Ti.UI.Label', bindId: 'theName', properties: { color:'black', font:{fontSize:14,fontWeight:'bold'}, top:1, left:8, } }, { type: 'Ti.UI.Label', bindId: 'theCategorie', properties: { color:'darkGray', font:{fontSize:14,fontWeight:'bold'}, bottom:1, left:8, } }, ] }; var b1 = Ti.UI.createButton({ title : 'dataset1', top:20, }); b1.addEventListener('click', function() { var data1 = [ { theName: { text: 'Row 1'},theCategorie:{ text: 'Cat 1'} }, { theName: { text: 'Row 2'},theCategorie:{ text: 'Cat 2'} }, { theName: { text: 'Row 3'},theCategorie:{ text: 'Cat 3'} } ]; var listSection1 = Titanium.UI.createListSection({items: data1,headerTitle: 'Data1 Custom Item Template'}); listView.sections=[listSection1]; rootWin.openWindow(win2); }); var win1= Ti.UI.createWindow({title:'Custom Item Template'}); win1.add([b1,]); var win2 = Ti.UI.createWindow(); var listView = Titanium.UI.createListView( {templates: { 'detailTemplate':detailTemplate }, defaultItemTemplate: 'detailTemplate', } ); listView.addEventListener('itemclick', function(e){ //alert ( JSON.stringify(e)); Ti.API.info(JSON.stringify(e)); var item = e.section.getItemAt(e.itemIndex); Ti.API.info(JSON.stringify(item)); }); win2.add(listView); var rootWin = Ti.UI.iOS.createNavigationWindow({window:win1}); rootWin.open();TEST CASE with a builtin Template: click on 'dataset' to display the listView in the second window. Go Back click again on dataset RESULT: listItems are displayed.
var b1 = Ti.UI.createButton({ title : 'dataset1', top:20, }); b1.addEventListener('click', function() { var data1 = [ { properties : { title: 'Row 1',subtitle: 'Cat 3' }}, { properties : {title: 'Row 2',subtitle: 'Cat 4' }}, { properties : {title: 'Row 3',subtitle:'Cat 5' }} ]; var listSection1 = Titanium.UI.createListSection({items: data1,headerTitle: 'Data1 BUILT-IN TEMPLATE'}); listView.sections=[listSection1]; rootWin.openWindow(win2); }); var win1= Ti.UI.createWindow({title :'Built-in Template'}); win1.add([b1]); var win2 = Ti.UI.createWindow(); var listView = Titanium.UI.createListView( {defaultItemTemplate:Titanium.UI.LIST_ITEM_TEMPLATE_SUBTITLE,} ); listView.addEventListener('itemclick', function(e){ //alert ( JSON.stringify(e)); Ti.API.info(JSON.stringify(e)); var item = e.section.getItemAt(e.itemIndex); Ti.API.info(JSON.stringify(item)); }); win2.add(listView); var rootWin = Ti.UI.iOS.createNavigationWindow({window:win1}); rootWin.open();Pull pending against master https://github.com/appcelerator/titanium_mobile/pull/4715
For now use this workaround on older titanium releases.
b1.addEventListener('click', function() { var data1 = [ { theName: { text: 'Row 1'},theCategorie:{ text: 'Cat 1'} }, { theName: { text: 'Row 2'},theCategorie:{ text: 'Cat 2'} }, { theName: { text: 'Row 3'},theCategorie:{ text: 'Cat 3'} } ]; var listSection1 = Titanium.UI.createListSection({items: data1,headerTitle: 'Data1 Custom Item Template'}); listView.sections=[listSection1]; //BLOCKER BUG TIMOB-15278. THIS IS A WORKAROUND. SET THE TEMPLATES AGAIN listView.templates = {'detailTemplate':detailTemplate}; rootWin.openWindow(win2); });tested with 3.2.0.v20130919154842 and there is another problem if you use listView.appendSection() right now: TEST CASE: run the following code on 3.2.0.v20130919154842, click on 'dataset': the first time, dataItems are not displayed, second time all is OK. the only change is line 52
detailTemplate = { childTemplates: [ { type: 'Ti.UI.Label', bindId: 'theName', properties: { color:'black', font:{fontSize:14,fontWeight:'bold'}, top:1, left:8, } }, { type: 'Ti.UI.Label', bindId: 'theCategorie', properties: { color:'darkGray', font:{fontSize:14,fontWeight:'bold'}, bottom:1, left:8, } }, ] }; var b1 = Ti.UI.createButton({ title : 'dataset1', top:20, }); b1.addEventListener('click', function() { var data1 = [ { theName: { text: 'Row 1'},theCategorie:{ text: 'Cat 1'} }, { theName: { text: 'Row 2'},theCategorie:{ text: 'Cat 2'} }, { theName: { text: 'Row 3'},theCategorie:{ text: 'Cat 3'} } ]; var listSection1 = Titanium.UI.createListSection({items: data1,headerTitle: 'Data1 Custom Item Template'}); listView.appendSection(listSection1); rootWin.openWindow(win2); }); var win1= Ti.UI.createWindow({title:'Custom Item Template'}); win1.add([b1,]); var win2 = Ti.UI.createWindow(); var listView = Titanium.UI.createListView( {templates: { 'detailTemplate':detailTemplate }, defaultItemTemplate: 'detailTemplate', } ); listView.addEventListener('itemclick', function(e){ //alert ( JSON.stringify(e)); Ti.API.info(JSON.stringify(e)); var item = e.section.getItemAt(e.itemIndex); Ti.API.info(JSON.stringify(item)); }); win2.add(listView); var rootWin = Ti.UI.iOS.createNavigationWindow({window:win1}); rootWin.open();Backport to 3_1_X https://github.com/appcelerator/titanium_mobile/pull/4722