简体   繁体   中英

ExtJS Combo selected value

Iam design ExtJs Combo and bind from database

var AddEditPeopleStoreCompanyLocation = new Ext.data.JsonStore
        ({
            id: 'AddEditPeopleStoreCompanyLocation',
            fields: ['DID', 'Name'],
            url: '@Url.Content("~/Admin/GetCompanyLocations")',
            //data: [["1", "Head Quaters"], ["2", "Main"]],
            root: 'EntityArr',
            idProperty: 'KID',
            totalProperty: 'ArrayLength',
            remoteSort: true,
            autoDestroy: true,
            autoLoad: true
        });

my requirment is when i cilk on save button i have find out selected value of combo in controller for this iam using

public void InsertOrUpdateContactDetails(FormCollection FC)
        {
//
}

so how to get selected value of combo in this above function thanks in advance

When you click the "save" button you have to run the "submit" method of the form panel's layout and send your Combobox value inside a parameter, example:

var comboBox = new Ext.form.ComboBox({
    //...
    id: 'comboBox',
    name: 'comboBox'
});

var formPanel = new Ext.form.FormPanel({
    //...
    id: 'formPanel',
    items: [comboBox],
    buttons: [{
        text: 'Submit',
        handler: submitForm
    }]
});

var submitForm = function () {
        var formPanel = Ext.getCmp("formPanel")
        formPanel.form.submit({
            url: example.jsp,
            success: function (form, action) {
                alert("success")
            },
            failure: function (form, action) {
                alert("failure")
            }
        });
    };

Then you can use the comboBox parameter at server-side, it comes in "example.jsp".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM