Extjs4 链式组合

发布于 2025-01-06 06:22:31 字数 2101 浏览 4 评论 0原文

我有一套 2 个组合盒。一种是国家组合,另一种是州组合。默认情况下,当我选择一个国家/地区时,状态组合存储为空,然后根据组合值字段状态组合必须根据第一个组合进行过滤/加载。在 Extjs2.0 中,这在 Extjs4 中发生了什么变化。

国家商店

var country_store = Ext.create('Ext.data.Store', {
    //autoLoad: true,
    fields: ['id','c_id','c_name'],
    proxy: {
        type: 'ajax',
        url: 'country_list.php',
        reader: {
           type:'json',
           root: 'results'
        }
    },
    storeId: 'edu_context_store'
});

国家商店

var state_name = Ext.create('Ext.data.Store', {
autoLoad: true,
fields: ['id','s_id','s_name','parent_country_id'],
proxy: {
    type: 'ajax',
    url: 'states_list.php',
    reader: {
       type:'json',
       root: 'results'
    }
},
storeId: 'state_name'

});

组合框

{
            xtype: 'combo',
            id: 'country_combo',
            hiddenName: 'country_name',
            displayField: 'c_name',
            valueField: 'c_id',
            fieldLabel: 'Country',
            queryMode: 'remote',
            allowBlank: false,
            triggerAction: 'all',
            store: country_store,
            width: 450,
            selectOnFocus: true,
            listeners:{
            scope: this,
            'select': function(combo, rec, idx){
               var country_val = combo.getRawValue();
               var states_obj = Ext.getCmp('states_combo');        
                        states_obj.clearValue();
                        //states_obj.store.load();
                        states_obj.store.filter('parent_country_id', country_val);


            }                           
        }

        }, {
            xtype: 'combo',
            id: 'states_combo',
            hiddenName:'state_name',
            displayField:'s_name',
            valueField:'s_id',
            queryMode: 'remote',
            fieldLabel: 'State',
            cls: 'textlineht',
            allowBlank: false,
            triggerAction: 'all',
            store: states_store,
            width: 450

        }

有人知道该怎么做吗?

谢谢 !

I've a set of 2 combo boxes. One is countries combo and another is states combo. By default the states combo store is empty when I select a country then based on the combo value field States combo has to be filtered/load according to the first combo. In Extjs2.0 this is working whats the changes in Extjs4.

country store

var country_store = Ext.create('Ext.data.Store', {
    //autoLoad: true,
    fields: ['id','c_id','c_name'],
    proxy: {
        type: 'ajax',
        url: 'country_list.php',
        reader: {
           type:'json',
           root: 'results'
        }
    },
    storeId: 'edu_context_store'
});

State store

var state_name = Ext.create('Ext.data.Store', {
autoLoad: true,
fields: ['id','s_id','s_name','parent_country_id'],
proxy: {
    type: 'ajax',
    url: 'states_list.php',
    reader: {
       type:'json',
       root: 'results'
    }
},
storeId: 'state_name'

});

Combo boxes

{
            xtype: 'combo',
            id: 'country_combo',
            hiddenName: 'country_name',
            displayField: 'c_name',
            valueField: 'c_id',
            fieldLabel: 'Country',
            queryMode: 'remote',
            allowBlank: false,
            triggerAction: 'all',
            store: country_store,
            width: 450,
            selectOnFocus: true,
            listeners:{
            scope: this,
            'select': function(combo, rec, idx){
               var country_val = combo.getRawValue();
               var states_obj = Ext.getCmp('states_combo');        
                        states_obj.clearValue();
                        //states_obj.store.load();
                        states_obj.store.filter('parent_country_id', country_val);


            }                           
        }

        }, {
            xtype: 'combo',
            id: 'states_combo',
            hiddenName:'state_name',
            displayField:'s_name',
            valueField:'s_id',
            queryMode: 'remote',
            fieldLabel: 'State',
            cls: 'textlineht',
            allowBlank: false,
            triggerAction: 'all',
            store: states_store,
            width: 450

        }

Anyone knows how to do that ?

Thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆伤 2025-01-13 06:22:31

combo.getRawValue() 将返回组合中显示给用户的值 - 而不是底层 id 值。尝试使用combo.getValue()

combo.getRawValue() will return the value displayed to the user in the combo - not the underlying id value. Try instead combo.getValue().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文