Javascript Extjs捕获拾取事件(组合框)

Javascript Extjs捕获拾取事件(组合框),javascript,web,extjs,combobox,extjs4,Javascript,Web,Extjs,Combobox,Extjs4,使用extjs4.2.3。我有一个表单,里面有combobox字段和一些值。当用户在combobox中选择值的1时,我需要捕捉事件。 请求语法方面的帮助,例如获取拾取数据3值的警报。 组合框字段的名称-“文档类型”” ExtJS上的代码示例: documentForm\u window=Ext.create(“Ext.window.window”{ 标题:(document_GUID==null)?“[Create]”:“[Edit]”, 宽度:500, 莫代尔:是的, 布局:“适合”, 项目

使用extjs4.2.3。我有一个表单,里面有combobox字段和一些值。当用户在combobox中选择值的1时,我需要捕捉事件。 请求语法方面的帮助,例如获取拾取数据3值的警报。 组合框字段的名称-“文档类型”

ExtJS上的代码示例:

documentForm\u window=Ext.create(“Ext.window.window”{
标题:(document_GUID==null)?“[Create]”:“[Edit]”,
宽度:500,
莫代尔:是的,
布局:“适合”,
项目:[{
xtype:“表单”,
框架:对,
waitMsgTarget:是的,
听众:{
afterrender:函数(形式){
如果(文档GUID!=null){
form.getForm().load({
url:Ext.state.Manager.get(“MVC_url”)+“/Document/get”,
方法:“获取”,
参数:{document\u GUID:document\u GUID},
waitMsg:“[加载]”,
超时:300,
失败:功能(形式、动作){
if(action.result)Ext.Msg.alert(“[Error1]!”,action.result.errorMessage);
else Ext.Msg.alert(“[Error2]!”、“[Error3]!”);
}
});
}
}
},
默认值:{
主播:“100%”,
msgTarget:“侧边”,
标签宽度:145,
allowBlank:false
},
项目:[{
xtype:“组合”,
名称:“文件类型”,
字段标签:“[Type]*”,
显示字段:“文档类型\名称”,
valueField:“文档类型”,
queryMode:“本地”,
触发动作:“全部”,
可编辑:false,
存储:文档存储
}, {
xtype:“textfield”,
名称:“合同编号”,
字段标签:“[TestData]”
}],
是的,
按钮:[{
text:(document_GUID==null)?“[Create]”:“[Edit]”,
处理程序:函数(){
var action=(document_GUID==null)?“创建”:“编辑”;
var form=this.up(“form”).getForm();
if(form.isValid()){
提交表格({
url:Ext.state.Manager.get(“MVC_url”)+“/Document/”+操作,
参数:{document\u GUID:document\u GUID,tree\u value},
waitMsg:“[Loading…]”,
成功:功能(形式、行动){
documentForm_window.destroy();
OrderLines\u store.load({
范围:本,,
回调:函数(记录、操作、成功){
文档列表.query('*[itemId=“DATA1\u grid”]')[0].selModel.select(当前位置);
}
});
},
失败:功能(形式、动作){
if(action.result)Ext.Msg.alert(“[Error1]!”,action.result.Msg);
else Ext.Msg.alert(“[Error2]!”、“[Error3]!”);
}
});
}
}
}]
}]
}).show();
}
//存储//
document_store=new Ext.data.ArrayStore({
字段:[“文档类型”、“文档类型名称”],
数据:[[0,“数据1”],[1,“数据2”],[2,“数据3”]]
});

抱歉,我添加的部分代码是导致post错误的屏幕原因“看起来您的帖子主要是代码”。

您必须为组合框添加一个侦听器:

editable: false,
store: document_store,
listeners: {
    select: function(combo, records) {
        console.log(combo);
        console.log(records);
        if(!Ext.isArray(records)) records = [records];
        Ext.each(records, function(record) {
            if(record.get(combo.valueField)==3) {
               Ext.Msg.alert('Value is 3 for' + record.get(combo.displayField));
            }
        });
    }
}
editable: false,
store: document_store,
listeners: {
    select: function(combo, records) {
        console.log(combo);
        console.log(records);
        if(!Ext.isArray(records)) records = [records];
        Ext.each(records, function(record) {
            if(record.get(combo.valueField)==3) {
               Ext.Msg.alert('Value is 3 for' + record.get(combo.displayField));
            }
        });
    }
}