簡體   English   中英

ExtJS設置textareafield setValue()

[英]ExtJS setting a textareafield setValue()

我正在學習Extjs並遇到問題,當我嘗試將新文本附加到項目時我得到一個錯誤tf.setValue不是 getValue 的功能相同。 當我嘗試setVisible它的工作原理應該如此。

Ext.Loader.setConfig({enabled:true});

Ext.application({
    name: 'app',
    controllers:[
  ],
    appFolder: 'app',
    launch: function() {
        var panel = new Ext.form.FormPanel({
          renderTo:Ext.getBody(),
          title:'Panel',
          width:400,
          bodyPadding: 10,
          autoHeight:true,
          items:[{
            xtype:'textareafield',
            name: 'textInput',
            id:'textId',
            value:'why not'
          },{
            xtype:'button',
            text:'Helllo',
            handler:function(){
              console.log('button click')
              var tf = Ext.get('textId');
                    tf.setValue('This should change!')
            }
          }],
        });
    }
});

謝謝

那是因為Ext.get()將返回一個Ext.Element

你想要使用的是Ext.getCmp('textId') ,它將返回組件。

Element基本上是圍繞Dom元素的Ext包裝器,所以它有像setVisible這樣的方法,但是你想得到文本區域組件,它包含你想要的所有方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM