天天看点

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旁边的文本数据框就会显示出来,不然就是不可编辑状态