2011-02-18 24 views
0

我有一個nestedList - 當我到達最後的項目,我想調用一個處理程序,將面板交換到旋轉木馬。請參閱 - http://test.miaduk.com/mobile/TLE/顯示從nestedList傳送帶 - 可能使用處理程序?

不幸的是,我似乎無法得到任何處理程序來處理嵌套的項目,並不能想到另一種方式。我仍然是Sencha的初學者,所以任何幫助,將不勝感激。 謝謝!

見代碼:

Ext.setup({ 
icon: 'icon.png', 
tabletStartupScreen: 'tablet_startup.png', 
phoneStartupScreen: 'phone_startup.png', 
glossOnIcon: true, 
onReady: function() { 


    /*Data Store 
    *********************************************************************************/ 
var data = { 
    text: 'Categories', 
    items: [{ 
     text: 'Core Skills/Personal Development', 
     items: [{ 
      text: 'Fishbone Diagram', 
      leaf: true 
     },{ 
      text: '5 Whys Technique', 
      leaf: true 
     },{ 
      text: 'SMART Objectives', 
      leaf: true 
     },{ 
      text: 'Circle of Influence', 
      leaf: true 
     },{ 
      text: 'Managing Stress', 
      leaf: true 
     }] 
    },{ 
     text: 'Communication', 
     items: [{ 
      text: 'Listening Skills', 
      leaf: true 
     },{ 
      text: 'Giving Feedback', 
      leaf: true 
     },{ 
      text: 'Recieving Feedback', 
      leaf: true 
     }] 
    },{ 
     text: 'Customer Service', 
     items: [{ 
      text: 'Listening and Confirming', 
      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({ 
    fullscreen: true, 
    title: 'Categories', 
    displayField: 'text', 
    dock: 'top', 
    store: store 
}); 


    /*Carousel 
    *********************************************************************************/ 
    var carousel = new Ext.Carousel({ 
    fullscreen: true, 
    displayField: 'text', 
    dock: 'top', 
     defaults: { 
      cls: 'card' 
     }, 
     items: [{ 
      html: '<img src="drainImage1.png">' 
     }, 
     { 
      title: 'Tab 2', 
      html: '<img src="drainImage2.png">' 
     }] 
    }); 


    /*Tab Panel 
    *********************************************************************************/ 

    var tabpanel = new Ext.TabPanel({ 
     tabBar: { 
      dock: 'bottom', 
      layout: { 
       pack: 'center' 
      } 
     }, 
     fullscreen: true, 
     ui: 'light', 
     cardSwitchAnimation: { 
      type: 'slide', 
      cover: true 
     }, 

     defaults: { 
      scroll: 'vertical' 
     }, 
     items: [{ 
      title: 'My Courses', 
      html: '<h1>Course list to appear here</h1>', 
      iconCls: 'favorites', 
      cls: 'card2', 
      badgeText: '3', 
      dockedItems: nestedList 
     },{ 
      title: 'Sample', 
      cls: 'card2', 
      iconCls: 'user', 
      dockedItems: carousel 
     },{ 
      title: 'Help', 
      html: '<h1>Help</h1><p>Info on how to add to your home screen goes here</p>', 
      cls: 'card3', 
      iconCls: 'user' 
     }] 
    }); 

回答

1

檢查這個樣本從煎茶NestedList

http://dev.sencha.com/deploy/touch/examples/nestedlist/index.js

有一個 「leafitemtap」 事件,你可以連接到您的嵌套列表執行的回調:

nestedList.on('leafitemtap', function(subList, subIdx, el, e, detailCard) { 
     var ds = subList.getStore(), 
      r = ds.getAt(subIdx); 

     Ext.Ajax.request({ 
      url: '../../src/' + r.get('id'), 
      success: function(response) { 
       detailCard.setValue(response.responseText); 
      }, 
      failure: function() { 
       detailCard.setValue("Loading failed."); 
      } 
     }); 
    }); 
相關問題