Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15278] iOS: ListView with custom Template in navigationWindow - listItems not rendered after push/pop

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-09-19T22:05:49.000+0000
Affected Version/sRelease 3.1.0, Release 3.1.1, Release 3.1.2, Release 3.1.3
Fix Version/s2013 Sprint 19, 2013 Sprint 19 API, Release 3.1.4, Release 3.2.0
ComponentsiOS
Labels3.1.3, 3.2.0, ios, ios7, listitem, listsection, listview, navigationWindow
ReporterVincent
AssigneeVishal Duggal
Created2013-09-17T16:01:15.000+0000
Updated2013-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.

Comments

  1. Vincent 2013-09-17

    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();
       
       
  2. Vincent 2013-09-17

    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();
       
  3. Vishal Duggal 2013-09-18

    Pull pending against master https://github.com/appcelerator/titanium_mobile/pull/4715
  4. Vishal Duggal 2013-09-18

    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);
       });
       
  5. Vincent 2013-09-20

    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();
       
       
       
       
  6. Vishal Duggal 2013-09-20

    Backport to 3_1_X https://github.com/appcelerator/titanium_mobile/pull/4722
  7. Wilson Luu 2013-10-18

JSON Source