简体   繁体   English

ExtJS ComboBox不显示元素

[英]ExtJS ComboBox not displaying elements

I am having trouble getting a ComboBox in ExtJS to display the dropdown items. 我无法在ExtJS中获得ComboBox来显示下拉菜单项。 I originally was using an XmlStore to load the data dynamically, but to make sure that wasn't the problem, I took an existing ComboBox that uses a simple ArrayStore (and currently works elsewhere in my application) to see if it would work, still with no luck. 我最初使用的是XmlStore来动态加载数据,但是为了确保这不是问题,我使用了一个现有的ComboBox,该ComboBox使用一个简单的ArrayStore(目前可以在我的应用程序中的其他地方使用)来查看它是否仍然有效没有运气。

When using Chrome's developer tools, when I click on the ComboBox element, I get ext-all-debug.js:41166 - Uncaught TypeError: Cannot call method 'getStyle' of undefined and nothing shows up for a dropdown. 使用Chrome的开发人员工具时,当我单击ComboBox元素时,我得到ext-all-debug.js:41166 - Uncaught TypeError: Cannot call method 'getStyle' of undefined并且下拉菜单中没有显示任何内容。

Here is my code: 这是我的代码:

EventForm = Ext.extend(Ext.form.FormPanel, {
    constructor: function(config) {
        config = Ext.apply({
            items: [
                {
                    layout: 'column',
                    xtype: 'container',
                    items: [
                        {
                            layout: 'form',
                            xtype: 'container',
                            columnWidth: 0.5,
                            items: [
                                {
                                    fieldLabel: 'My Combo Box'
                                    name: 'mycombobox',
                                    xtype: 'combo',
                                    store: new Ext.data.ArrayStore({
                                        fields: ['size'],
                                        data: [
                                            ['50'],
                                            ['100'],
                                            ['150'],
                                            ['200']
                                        ]
                                    }),
                                    displayField: 'size',
                                    valueField: 'size',
                                    forceSelection: true,
                                    editable: false,
                                    triggerAction: 'all',
                                    mode: 'local',
                                    listWidth: 60,
                                    width: 60
                                }
                            ]
                        }, {
                            // another column here similar to above
                        }
                    ]
                }
            ]
        }, config);

        EventForm.superclass.constructor(config);
    }
});

You are not calling the constructor of EventForm's superclass correctly. 您没有正确调用EventForm的超类的构造函数。 Change the last line of your constructor function to read: 将构造函数的最后一行更改为:

EventForm.superclass.constructor.call(this, config);

Your data array must contain a list of objects, and the keys you provided by fields must be the keys your data refers to in those objects. 您的data数组必须包含对象列表,并且由fields提供的键必须是数据在这些对象中引用的键。 The correct syntax for your data array could be: 您的data数组的正确语法可能是:

data: [
    {'size':'50'},
    {'size':'100'},
    {'size':'150'},
    {'size':'200'}
]

(could be, because I have no chance right now to verify) (可能是因为我现在没有机会进行验证)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM