Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ExtJs 4.1.2基于另一个组合框更新或重新加载组合框_Javascript_Jquery_Json_Extjs_Combobox - Fatal编程技术网

Javascript ExtJs 4.1.2基于另一个组合框更新或重新加载组合框

Javascript ExtJs 4.1.2基于另一个组合框更新或重新加载组合框,javascript,jquery,json,extjs,combobox,Javascript,Jquery,Json,Extjs,Combobox,我想知道如何更新ExtJs组合框的列表值。例如,我有两个组合框。 一个组合框决定另一个组合框应具有的值。所以在选择了其中一些之后,, 我单击淹没列表(组合框)以查看值。但我没有得到反映 change: function (combofirst, record) { Ext.Ajax.request({ -- -- -- -- -- -- success: function (response) { var c

我想知道如何更新ExtJs组合框的列表值。例如,我有两个组合框。 一个组合框决定另一个组合框应具有的值。所以在选择了其中一些之后,, 我单击淹没列表(组合框)以查看值。但我没有得到反映

change: function (combofirst, record) {
    Ext.Ajax.request({
        -- -- --
        -- -- --
        success: function (response) {
                var combosecond = Ext.getCmp('defaultPackageType');
                //I am unable to update the combosecond from below snippet.
                combosecond.store = Ext.create('Ext.data.Store', {
                    fields: ['value', 'display'],
                    data: [
                            ["N", "No"],
                            ["A", "All accounts"]
                        ] //json response
                });
            },
            failure: function (record, action) {}
    });
});
简言之,如何更改仅使用ajax的ComboBox的值

希望有人能帮助我


谢谢

我也同意这一评论,即每次创建一个新商店并将其绑定到组合框并不是最佳解决方案。我真的不知道为什么要这样做,但这里有一个使用bindStore的工作示例:

对于值1的选择,数据从不同的url加载。
但我会考虑是否需要一个新的代理调用,以及是否可以通过使用过滤器或其他东西来实现您的需求。

使用wich ExtJs版本和框架?现代还是经典?必须用新数据更新存储数据(或重新配置组合)。作为最佳解决方案,您需要在第二个组合框存储的代理上设置一些参数并重新加载存储。重新分配combobox的存储不是最佳解决方案。
Ext.create('Ext.form.field.ComboBox', {
    // ...
    listeners: {
        change: {
            fn: function (cb) {

                Ext.Ajax.request({
                    url: 'https://jsonplaceholder.typicode.com/albums',
                    method: 'GET',
                    timeout: 60000,

                    success: function (response) {
                        var jsonResp = response.responseText;
                        let jsonObj = Ext.JSON.decode(jsonResp, true)

                        var combo2 = Ext.getCmp('myCombo2');
                        combo2.bindStore(Ext.create('Ext.data.Store', {
                            fields: ['id', 'title'],
                            data: jsonObj
                        }));
                    }
                });
            }
        }
    }
});