[转]Extjs combo数据绑定与获取

原文地址:http://www.cnblogs.com/loveme123/archive/2012/05/10/2494466.html

1、

配置combo:

{
                                columnWidth: .3,
                                layout: 'form',
                                border: false,
                                items: [{
                                    id: "txtP_Nation",
                                    name: "txtP_Nation",
                                    allowBlank: false,
                                    width: 130,
                                    fieldLabel: '民族',
                                    emptyText: '请选择民族',
                                    hiddenName: 'PM_id', //真正提交时此combo的name,请一定要注意
                                    xtype: 'combo',
                                    editable: false,
                                    store: strNation,//设置数据源
                                    displayField: 'PM_Name', //显示文本字段
                                    valueField: 'PM_id',//value值字段id
                                    mode: 'local',
                                    triggerAction: 'all',,//请设置为"all",否则默认为"query"的情况下,你选择某个值后,再此下拉时,只出现匹配选项,如果设为"all"的话,每次 下拉均显示全部选项
                                    selectOnFocus: true,
                                    typeAhead: true
                                }]
                            }

           2、数据源:

     var strNation = new Ext.data.Store({
                proxy: new Ext.data.HttpProxy(
                    {
                        url: '../form/Ala_HomeOtherPeople.ashx?cmd=GetParmater&type=nation'
                    }
                ),
                reader: new Ext.data.JsonReader(
                    { root: 'data' },
                    [
                        { name: 'PM_id', type: 'string' },//id
                        { name: 'PM_Name', type: 'string' }//名称
                    ]
                )
            });
            strNation.load();

编辑或修改数据时需要把要修改的数据显示在combo中:

  strNation.load({ callback: function () {
                    Ext.getCmp("txtP_Nation").setValue(json.P_Nation);//json.P_Nation 为数据id
                }
                });

获取combo选中的id值:

  var P_Nation = Ext.getCmp("txtP_Nation").getValue();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值