天天看點

Ext.js通過選擇ComboBox的值來監聽動作

實作通過選擇不同的值來展現不同的效果

var fieldType = new Ext.form.ComboBox({
            fieldLabel: '字段類型',
            store: new Ext.data.SimpleStore({
                fields: ["type"],
                data:[['String'],['Json']]
            }),
            displayField: 'type',
            valueField: 'type',
            typeAhead: true,
            mode: 'local',
            forceSelection: true,
            triggerAction: 'all',
            selectOnFocus: true,
            anchor: '-10',
            listeners: {
                select: function (combo, record) {
                    if (record.get('type') == 'String') {
                        splitSymbol.setDisabled(false);
                    } else {
                        splitSymbol.setDisabled(true);
                    }
                }
            }
        });
           
var splitSymbol = new Ext.form.TextField(
            {
                fieldLabel: '字段分割符',
                emptyText:"字段類型為String時輸入分割符,如,",
                anchor: '-10'
            });
           

看上面兩段代碼,comboBox監聽的方法中參數的意思是

Ext.js通過選擇ComboBox的值來監聽動作

第三個參數我沒用到也就沒加,其中type對應的是comboBox中你的valueField,擷取目前選擇的值然後比較,此功能就是選擇了String旁邊的文本資料框就會顯示出來,不然就是不可編輯狀态