Results 1 to 5 of 5

Thread: using templates in sencha touch 2

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    18
    Vote Rating
    0
      0  

    Default using templates in sencha touch 2

    hi, Im trying to use templates in sencha touch 2.
    But I don't know how to add the data, i followed the instructions of the video (www.sencha.com/learn/xtemplates-part-i/ and www.sencha.com/learn/xtemplates-part-ii/ )
    and i replaced .update() with data :
    this is my code :

    Code:
    Ext.application({
        name: 'Sencha',
        launch: function() {
            var theContents = [
                                {icon : "image1.jpg" , title : "title1"},
                                {icon : "image2.png" , title : "title2"},
                                {icon : "image3.jpg" , title : "title3"},
                                {icon : "image4.jpg" , title : "title4"},
                                {icon : "image5" , title : "title5"},
                                 ];
    
    
             var contentInfo = Ext.XTemplate.from("content-template");
    
    
             var theSlideList = {
                     layout : 'hbox',
                     scrollable: {
                         direction: 'horizontal'
                     },
                     height : '120px',
                     width : '100%',
                     tpl: contentInfo,
                    data: theContents
             };
    
    
    
    
             var bigPanel = {
                     xtype : 'nestedlist',
                     title : 'big panel',
                     iconCls: 'star',
                     displayField: 'title',
                     layout:'vbox',
                     scrollable: {
                         direction: 'vertical'
                     },
                     items : [
                             theTitle,/*an html item*/
                             theSlideList,
                            /*other items*/
                             
                     ]
             };
             
             Ext.Viewport.add({
                xtype: 'tabpanel',
                tabBarPosition: 'bottom',
                items: [
                    bigPanel,
                    otherTabItem
                    ] 
                });
        }
    });
    It's giving me the error
    Uncaught TypeError: Cannot read property 'type' of undefined

    if i remove the attribute data from 'theSlideList' everything works but the contents are not shown.
    Any idea on how i should be doing this ?
    Thank you



  2. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,029
    Answers
    3976
    Vote Rating
    1367
      0  

    Default

    You shouldn't add items to the NestedList and change it's layout. If you don't like the way NestedList operates then I would create your own version instead of hacking up NestedList.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    18
    Vote Rating
    0
      0  

    Default

    what's wrong with what I've done with nestedLists? I should simply remove layout : 'vbox'<br>or use another xtype ? what i've done is use the example of "getting started", the nestedList nad replaced the data with my data.<br>I'm still in my first week of sencha touch, so any advice is greatly appreciated <br>Thanks

  4. #4
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,029
    Answers
    3976
    Vote Rating
    1367
      0  

    Default

    NestedList is a Container using card layout and it's items are Lists (except the detail card). You are trying to change the layout where it uses setActiveItem internally which then it won't work as expected.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    18
    Vote Rating
    0
      0  

    Default

    Ah ok, got the point.
    Thank you

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •