2012-04-06 56 views
0

我有一個由工具欄和選項卡組成的面板。在每個選項卡上應該有一個列表和一個按鈕。我相信我有這個正確設置除了名單,我想補充如下:Sencha Touch 2:嘗試向面板添加列表

Ext.define('Myapp.view.Search', { 
xtype: 'search', 
extend: 'Ext.tab.Panel', 

    config: { 
     activeItem: 0, 
     tabBar: { 
      docked: 'top', 
      autoScroll: 'auto', 
      ui: 'light', 
      layout: { 
       pack: 'center' 
      } 
     }, 

     items: [ 
     { 
      xtype:'toolbar', 
      docked:'top', 
      ui: 'light', 
      title: 'Search' 
     }, 

      { 
       title: 'Tab 1', 
       xtype: 'formpanel', 
       items: [ 
        { 
         xtype: 'Mylist' //DOES NOT WORK 
        }, 
        { 
         xtype: 'panel', 
         defaults: { 
          xtype: 'button', 
          style: 'margin: 0.1em', 
          flex : 1 
         }, 
         layout: { 
          type: 'hbox' 
         }, 
         items: [ 
          { 
           text: 'Button 1', 
          } 
         ] 
        } 
       ] 
      }, 
      { 
       title: 'Tab 2', 
       xtype: 'formpanel', 
       items: [ 
        { 
         xtype: 'panel', 
         defaults: { 
          xtype: 'button', 
          style: 'margin: 0.1em', 
          flex : 1 
         }, 
         layout: { 
          type: 'hbox' 
         }, 
         items: [ 
          { 
           text: 'Button 1', 
          } 
         ] 
        } 
       ] 
      } 
     ] 
    } 
}); 

請讓我知道我做錯了,感謝您的幫助!

編輯:下面加MYLIST:

Ext.define('Myapp.view.Mylist', { 
    extend: 'Ext.dataview.NestedList', 
    xtype: 'Mylist', 

    config: { 
     store: 'Sections' 
    }, 

    getTitleTextTpl: function() { 
     return '{name}'; 
    }, 
    getItemTextTpl: function(node) { 
     return '<strong>{name}</strong>'; 
    }, 
}); 
+0

y是什麼y我們的清單代碼看起來像? – fuzzyLikeSheep 2012-04-06 21:36:07

+0

@fuzzyLikeSheep編輯我原來的帖子,包括 – Arkady 2012-04-06 21:44:55

回答

0

如果你在你的列表視圖定義你的列表,你應該說

alias:'widget.Mylist' 

,而不是

xtype:'Mylist' 

也是你的列表需要一個itemTpl配置我很確定。

config: { 
     store: 'Sections', 
     itemTpl:'{example}' 
    } 

而且只要驅動列表中的商店是在加工形狀列表中要正確

+0

得到它的工作!我失蹤的主要事情是itemTpl。非常感謝您的幫助 – Arkady 2012-04-12 15:34:12

1

顯示嘗試在查看這些

:在控制器

 { 
     xtype: 'panel', 
     flex: 4, 
     width: '400px', 
     height:"700px", 


     layout: { 
      type: 'fit' 
       }, 
     items: [ 
       { 
       xtype: 'list', 
      // loadingText:"Loading Category", 
       styleHtmlContent: true, 
       // id:"mylist2", 
       width:"300px", 


       itemTpl: 

      '<div class="mycon">'+ 
      '<input type="image" id="click" img src="{coupon_image}" style="max-width:130%;border:6px double #000000;" width="200" height="200"' +'style="padding:3px;">' + 
      '</div>'+ 
      '<div><font size="2" color="red"><b>Coupon Name:</b></font></div>'+ 
      '<div><font size="2" color="green"><b>{coupon_name}</b></font></div>'+ 


       '</div>',         
       store : 'ViewCategoryStore', 


      }, 


     ] 
    } 

 Ext.define('Expressdeal.controller.ViewCategoryController', { 
    extend: 'Ext.app.Controller', 

      config: { 
      refs: { 


     viewcat : 'viewcategory'  // xtype of the view 

       }, 
      control: { 


    'viewcategory list: { 
       activate: 'onActivate', 
       itemtap: 'onItemTap', 
        },