2012-02-09 118 views
1

我開始使用sencha touch。我已經能夠創建一個嵌套列表佈局,點擊一個葉子元素觸發一個getdetailcard。現在我想做一些與此相反的事情。如何從通用主頁滑動到sencha touch中的嵌套列表佈局

我想現在創建一個沒有任何內容的主頁,而是一個標誌。當用戶點擊徽標時,佈局會滾動到項目的嵌套列表。

有人可以指點我的相關文檔或向我展示示例代碼嗎?

感謝

回答

1

您需要將面板卡添加到您的視口,然後在水龍頭標誌更改活動項目。

下面是示例代碼:

var data = { 
    text: 'Groceries', 
    items: [{ 
     text: 'Drinks', 
     items: [{ 
      text: 'Water', 
      items: [{ 
       text: 'Sparkling', 
       leaf: true 
      }] 
     }] 
    }] 
}; 
Ext.regModel('ListItem', { 
    fields: [{name: 'text', type: 'string'}] 
}); 
var store = new Ext.data.TreeStore({ 
    model: 'ListItem', 
    root: data, 
    proxy: { 
     type: 'ajax', 
     reader: { 
      type: 'tree', 
      root: 'items' 
     } 
    } 
}); 
var nestedList = new Ext.NestedList({ 
    title: 'Groceries', 
    displayField: 'text', 
    store: store 
}); 

var MyApp = new Ext.Application({ 
    name: 'MyApp', 
    launch: function() { 
     MyApp.views.viewport = new Ext.Panel({ 
      fullscreen: true, 
      layout: 'card', 
      cardAnimation: 'slide', 
      items: [ 
       { 
       xtype: 'panel', 
        html:'<img src="https://www.google.com/intl/en_com/images/srpr/logo3w.png">', 
        listeners:{ 
         el:{tap:function(){MyApp.views.viewport.setActiveItem(1,{type:'slide',direction:'left'});}} 
        } 
       }, 
       nestedList 
      ] 
     }); 
    } 
});