grid toolbar 中 Combobox 的问题

TestGrid 继承自 gridpanel,toolbar中有两个combobox, 一个添加按钮, 一个删除按钮, 点击添加按钮时,取得两个combobox的内容, 添加到grid中,代码如下:

/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//alert grid
TestGrid = function(){
    this.facilitycombox = new Ext.form.ComboBox({
        id : 'fc',
        name : 'facility',
        fieldLabel: 'Facility',
        store : new Ext.data.SimpleStore({ fields: ['value'], data : this.facilities }),
        displayField:'value',
        typeAhead: true,
        mode: 'local',
        selectOnFocus:true,
        allowBlank:false,
        emptyText : 'Select a facility...',
        triggerAction: 'all',
        listeners:{ scope: this }
        //scope : this
    });
    this.levelcombox = new Ext.form.ComboBox({
        id : 'lc',            
        name : 'level',
        fieldLabel: 'Level',
        store : new Ext.data.SimpleStore({ fields: ['name','val'], data : this.levels }),
        displayField:'name',
        valueField :'val',
        typeAhead: true,
        mode: 'local',
        selectOnFocus:true,
        allowBlank:false,
        emptyText : 'Select a level...',
        triggerAction: 'all',
        listeners:{scope: this }
        //scope : this
    })
    this.topbar = new Ext.Toolbar({
        scope : this,
        items :[
            this.facilitycombox,
            '-',
            this.levelcombox,
            '-',
            {
                id : "addbtn",
                text : "Add",
                pressed:true,
                tooltip:'Add an alert event',
                handler: this.addAlert
            },
            '-',
            {
                id : "delbtn",
                text : "Delete",
                pressed:true,
                tooltip:'Delete alert events',
                handler: this.deleteAlert
            }
        ]
    })
    this.sm = new Ext.grid.CheckboxSelectionModel();
    this.cm = new Ext.grid.ColumnModel([     
        new Ext.grid.RowNumberer(),
        this.sm,       
        {
            //id: 'facility',
            header: "Facility",
            dataIndex: 'facility',
            width: 60
        },
        {
            header: "Level",
            dataIndex: 'level',
            width: 40
        }        
    ]);
    this.myData = [[' ',' ']];
    this.ds = new Ext.data.Store({
        proxy:new Ext.data.MemoryProxy(this.myData),
        reader:new Ext.data.ArrayReader({id:0}, [
            {name:"facility"},
            {name:"level"}
        ])
    });
    //this.ds.load();
    this.cm.defaultSortable=true;
    TestGrid .superclass.constructor.call(this, {
        title : 'Edit alert event',
        width:600,
        height:300,
        store: this.ds,
        cm: this.cm,
        sm : this.sm,
        loadMask: true,
        autoScroll:true,
        viewConfig: { forceFit:true },        
        tbar : this.topbar
    })
}
Ext.extend(TestGrid , Ext.grid.GridPanel, {
    facilities : [['Kern'],['User'],['Mail'],['Daemon'],['Auth'],
        ['Syslog'], ['Lpr'],['News'],['Uucp'],['Cron'],
        ['System0'],['System1'],['System2'],['System3'],['System4'],['System5'],
        ['local0'],['local1'],['local2'],['local3'],['local4'],['local5'],['local6'],['local7']],
    levels : [['Emerg','0'],['Alert','1'],['Crit','2'],['Err','3'],['Warn','4'],['Notice','5'],['Info','6'],['Debug','7']],
    addAlert : function (){
        var f = this.levelcombox.getValue();
        alert(f);
    },
    deleteAlert : function(){}
})

 运行的时候,错误信息为 :this.levelcombox has no properties

现在无法取得combobox的值,如何实现这个功能? 谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值