Extjs4 链式组合 [英] Extjs4 Chained combos

查看:46
本文介绍了Extjs4 链式组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

乡村商店

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

        }

有人知道怎么做吗?

谢谢!

推荐答案

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().

这篇关于Extjs4 链式组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆