2012-07-24 30 views
0

我是所有Sencha Touch東西的新手,但直到現在,我對它的功能非常敬畏。有一個問題,我無法解決。Sencha Touch:XTemplate在DataView中不可見

我想使用Tpl(XTemplate)進行日曆視圖。這個想法是爲每個約會創建一個div元素,我可以將它放在容器中來佈置它們。不知何故,我無法獲得數據視圖的工作。

我把我的代碼剝離到最低限度:一個包含DataView的面板。當我使用itemTpl時,一切正常。但是當我使用tpl(有或沒有XTemplate)時,我什麼都看不到。我檢查了它是否僅僅是一個顯示故障(從模板中搜索了XXX),但事實並非如此。

這是我的代碼:

Ext.define('InfoApp.view.CalendarDay', { 
extend: 'Ext.Panel', 
xtype: 'calendarday', 
requires: [ 'InfoApp.store.sAppointments'], 
config: { 
    title: 'Dag', 
    layout: 'fit', 
     items: [ 
       { 
        xtype: 'dataview', 
        store: 'appointmentStore', 

        //itemTpl: [ 'XXX {day} {course}' ] --> Works 
        tpl: new Ext.XTemplate('<tpl for=".">XXX {day} {course}</tpl>')--> Doesn't Work... 
       }   
     ] 
} 
}); 

在此先感謝您的任何建議或改進!

回答

0

坦克@brink爲您的答案。

我花了一兩天,但這個工作對我來說:

// Load the store 
    var store = Ext.getStore('appointmentStore'); 

    // Get the current range of the store 
    var data = store.getRange(); 

    // Create a custom template 
    var tpl = new Ext.XTemplate(<tpl for=".">{day} {course}</tpl>); 

    // Loop through the data array 
    var showData = array(); 
    for(var i=0;i<data.length;i++){ 
     showData.push(data[i].data); 
    } 

    // Get the panel by ID and push the html template 
    var panel = Ext.getCmp('appointmentspanel'); 
    panel.updateHtml(tpl.applyTemplate(showData));  
0

假設ST2和ST1不

http://docs.sencha.com/touch/2-0/#!/api/Ext.Component-cfg-tpl和對第三方物流的評論:配置在該文檔中,它出現使用遠程存儲時有一個錯誤。即使你的商店有數據。你可以使用itemTpl:new XTemplate()或itemTpl:XTemplate.from('someid'),或者你可以推遲指定,直到以後,抓住你的數據視圖,並去dv.setItemTpl(新XTemplate())等。

相關問題