Extjs中隱藏某個textfield以及label組件的方法

其實很簡單,我做的就是在選擇combox某一項的時候使得textfield和label出現

首先設置相對應的textfield和label   hidden爲true使其隱藏,然後給他們添加上id

其次在combox中添加個時間listerns  通過index 獲取點擊的是那一個,然後用Ext.getCmp(id)方法獲取組建,讓他們setVisible(true)就好了

就是這麼簡單,你學會了麼?

{
    // 類型
    width : 180,
    xtype : 'combo',

   store : new Ext.data.SimpleStore({
   fields: ['id', 'genre'],
   data : [
          ['0','New Genre'],
          ['1','Comedy'],
          ['2','Drama'],
          ['3','Action']
             ]
     }),
    valueField : 'name',
    editable : false,
    readOnly : true,
    displayField : 'text',
    mode : 'local',
    triggerAction : 'all',
    fieldLabel : Jer.Global.BUNDLE
      .getMsg("TopicSet.TopicTableType"),
    hiddenName : 'topicTableType',
    name : 'topicTableType',
    listeners : {
     select : function(combo, record, index){
      if(index == 2){
       Ext.getCmp('csql').setVisible(true);
       Ext.getCmp('connCode').setVisible(true);
      }
     }
    }
   },
   {
    id : 'csql',
    xtype : 'textarea',
    width : 300,
    height : 50,
    name : 'createSql',
    hidden : true,
    fieldLabel : Jer.Global.BUNDLE.getMsg("TopicTable.CreateSql")
   },

   {
    id : 'connCode',
    xtype : 'combo',
    name : 'connectionCode',
    inputValue : 'true',
    readOnly : false,
    editable : false,
    hidden : true,
    triggerAction : 'all',
    fieldLabel : Jer.Global.BUNDLE.getMsg("TargetConnectionPool"),
    mode : 'local',
    allowBlank : true,
    store : new Ext.data.Store(
      {
       proxy : new Ext.data.HttpProxy(
         {
          url : 'ExtControllerServlet?action=connectionPoolAction.findAllWithEmpty'
         }),
       reader : new Ext.data.JsonReader({
        root : 'data',
        totalCount : 'totalCount'
       }, [ {
        name : 'id'
       }, {
        name : 'code'
       }, {
        name : 'text'
       } ]),
       autoLoad : true
      }),
    displayField : 'text'
   } ],

在附上幾個方法:setDisplay(),setVisible(),show(),hide()

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章