2011-04-13 9 views
11

मैं Ext.panel में गतिशील रूप से एक नया आइटम कैसे जोड़ सकता हूं? यह वह कोड है जिसका मैं उपयोग कर रहा हूं;सेन्चा टच गतिशील रूप से आइटम

app.views.ViewItem = Ext.extend(Ext.Panel, { 
    id: '0', 
    dockedItems: [{ 
     xtype: 'toolbar', 
     title: 'Melvin test', 
     items: [ 
      { 
       text: 'Terug', 
       ui: 'back', 
       listeners: { 
        'tap': function() { 
         Ext.dispatch({ 
          controller: app.controllers.appController, 
          action: 'backToRssList', 
          animation: {type:'slide', direction:'right'} 
         }); 
        } 
       } 
      }, 
      {xtype:'spacer'}, 
      { 
       id: 'share', 
       text: 'Delen', 
       ui: 'action', 
       listeners: { 
        'tap': function() { 
         Ext.dispatch({ 
          controller: app.controllers.appController, 
          action: 'share', 
         }); 
        } 
       } 
      } 
     ] 
    }], 
    items: [], 
    initComponent: function() { 
     app.views.ViewItem.superclass.initComponent.apply(this, arguments); 
    }, 
    getView: function(data) { 
     //this.items.add({html: 'test'}); 
    }, 
}); 

फ़ंक्शन में देखें व्यू मैं इस पंक्ति के साथ एक नया आइटम जोड़ने की कोशिश कर रहा हूं;

this.items.add({html: 'test'}); 

दिखा रहा है कि त्रुटि (Rockmelt, क्रोम में) है;

Uncaught TypeError: Object #<Object> has no method 'getItemId' 

स्पष्ट रूप से यह काम नहीं कर रहा है, मैं क्या गलत कर रहा हूं?

उत्तर

16

क्या आपने पैनल के लिए add() फ़ंक्शन का उपयोग करने का प्रयास किया था? E.g:

this.add({html: 'test'}); 
+0

धन्यवाद, यह काम कर रहा है! – Melvin

+0

@ user706933 फिर से इस पर उत्तर के लिए धन्यवाद, लेकिन प्रश्न को बंद करने के लिए उत्तर को सही के रूप में चिह्नित करें। – sra

+0

धन्यवाद यह मेरे लिए काम कर रहा है –

संबंधित मुद्दे