+ -
当前位置:首页 → 问答吧 → 关于ext combox既可以选择列表中的值,也可以输入列表中的值,如果没有对应的值 则为空

关于ext combox既可以选择列表中的值,也可以输入列表中的值,如果没有对应的值 则为空

时间:2011-09-02

来源:互联网

关于ext combox既可以选择列表中的值,也可以输入列表中的值,如果列表中没有对应的值(随便输入的,不认) 则为空

作者: jiery666   发布时间: 2011-09-02

我的代码如下 ,现在的情况是只能输入列表中的第一项,输入下面的项
return "<b><font color=#008B8B>" + hwlx_Store.getAt(value - 1).data.name + "</font></b>";这行就出错  
提示 "Microsoft JScript 运行时错误: 'hwlx_Store.getAt(...).data' 为空或不是对象"
JScript code
 var combo_hwlx = new Ext.form.ComboBox({
        store: hwlx_Store,
        id: 'hwlx_add',
        hiddenName: 'com_hwlxhidden',
        fieldLabel: '货物名称',
        width: 70,
        typeAhead: true,
        emptyText: '请选择...',
        triggerAction: 'all',
        valueField: 'id',
        displayField: 'name',
        loadingText: 'loading...',
        selectOnFocus: true,
        allowBlank: false,
        editable: false,
        mode: 'local',
        blankText: '请选择货物名称'
    });
 var cm_add = new Ext.grid.ColumnModel([
        {header: '货名', dataIndex: 'hwmc_add', id: 'hwmc_add', width: 60, editor: new Ext.form.TextField({}),
        renderer: function(value, meta, record, rowIndex, colIndex, store) {
            if (value < 1) {
                return "";
            }
            else {
                return "<b><font color=#008B8B>" + hwlx_Store.getAt(value - 1).data.name + "</font></b>";
            }
        },
        editor: new Ext.form.ComboBox({
            tpl: '<tpl for="."><div ext:qtip="{id}. {name}" class="x-combo-list-item">{name}</div></tpl>',
            store: hwlx_Store,
            typeAhead: true,
            forceSelection: true,
            triggerAction: 'query',
            selectOnFocus: true,
            width: 100,
            editable: true,
            displayField: 'name',
            valueField: 'id',
            hiddenName: 'hwlx_addhidden',
            mode: 'local',
            frame: true,
            resizable: true
        })
    }



作者: jiery666   发布时间: 2011-09-03