mercredi 20 décembre 2017

Extjs Catch pick event (combobox)

Using ExtJS 4.2.3. I have FORM with combobox field and some values inside on choose. I need to catch event when user pick 1 of the value in combobox. Asking for help with syntax, as example to get ALERT on picking DATA3 value. Name of combobox field - "document_type".

Example of code on ExtJS:

enter image description here

        documentForm_window = Ext.create("Ext.window.Window", {
            title: (document_GUID == null) ? "[Create]" : "[Edit]",
            width: 500,
            modal: true,
            layout: "fit",
            items: [{
                xtype: "form",
                frame: true,
                waitMsgTarget: true,
                listeners: {
                    afterrender: function (form) {
                        if (document_GUID != null) {
                            form.getForm().load({
                                url: Ext.state.Manager.get("MVC_url") + "/Document/Get",
                                method: "GET",
                                params: { document_GUID: document_GUID },
                                waitMsg: "[loading]",
                                timeout: 300,
                                failure: function (form, action) {
                                    if (action.result) Ext.Msg.alert("[Error1]!", action.result.errorMessage);
                                    else Ext.Msg.alert("[Error2]!", "[Error3]!");
                                }
                            });
                        }
                    }
                },
                defaults: {
                    anchor: "100%",
                    msgTarget: "side",
                    labelWidth: 145,
                    allowBlank: false
                },
                items: [{
                    xtype: "combo",
                    name: "document_type",
                    fieldLabel: "<b>[Type]<font color='Red'>*</font></b>",
                    displayField: "document_type_name",
                    valueField: "document_type",
                    queryMode: "local",
                    triggerAction: "all",
                    editable: false,
                    store: document_store
                }, {
                    xtype: "textfield",
                    name: "contract_number",
                    fieldLabel: "<b>[TestData]</b>"

                }],
                formBind: true,
                buttons: [{
                    text: (document_GUID == null) ? "[Create]" : "[Edit]",
                    handler: function () {
                        var action = (document_GUID == null) ? "Create" : "Edit";

                        var form = this.up("form").getForm();
                        if (form.isValid()) {
                            form.submit({
                                url: Ext.state.Manager.get("MVC_url") + "/Document/" + action,
                                params: { document_GUID: document_GUID, treasury_GUID: tree_value },
                                waitMsg: "[Loading...]",
                                success: function (form, action) {
                                    documentForm_window.destroy();
                                    OrderLines_store.load({
                                        scope: this,
                                        callback: function (records, operation, success) {
                                            documents_List.query('*[itemId="DATA1_grid"]')[0].selModel.select(curr_position);
                                        }
                                    });
                                },
                                failure: function (form, action) {
                                    if (action.result) Ext.Msg.alert("[Error1]!", action.result.msg);
                                    else Ext.Msg.alert("[Error2]!", "[Error3]!");
                                }
                            });
                        }
                    }
                }]
            }]
        }).show();
    }
//store//   
     document_store = new Ext.data.ArrayStore({
        fields: ["document_type", "document_type_name"],
        data: [[0, "data1"], [1, "data2"], [2, "data3"]]   
    });

Sorry, part of code I add as screen cause of post error "It looks like your post is mostly code".




Aucun commentaire:

Enregistrer un commentaire