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

posted on 2012-05-10 15:52  寒雪儿  阅读(7740)  评论(1编辑  收藏  举报