ExtJS 组合框数组

发布于 2024-12-19 09:04:10 字数 723 浏览 2 评论 0原文

我想使用以下数组创建一个组合框:

var operators = new Array(">=",">","=~","","!=","=","<","<=");

问题是我希望第一个元素(有时是最后一个元素)成为组合框的默认值。我找不到如何成功地做到这一点。

非常感谢,如果重复的话抱歉。

编辑

var ops = new Array(">=",">","=~","","!=","=","<","<=");
var operators = new Ext.data.ArrayStore({ id: 0, fields: [ 'value' ], data: ops });

Ext.getCmp('variablesAttributesPanel').add({xtype: 'combo',     id: variables[j].getTitle() + 'MinCombo', mode: 'local', valueField: 'value', displayField: 'value', store: operators,  width: 50,  x: 240, y: (j * 20 + 19), editable: false, allowBlank: false});

这是使下拉列表中的选项>、=、、、!、<

有什么想法吗?

I want to create a combobox with the following array:

var operators = new Array(">=",">","=~","","!=","=","<","<=");

The issue is that I would like the first element (and sometimes the last element) to be the default value of the comboxbox. I could not find how to successfully do this.

Thanks so much and sorry if duplicate.

EDIT

var ops = new Array(">=",">","=~","","!=","=","<","<=");
var operators = new Ext.data.ArrayStore({ id: 0, fields: [ 'value' ], data: ops });

Ext.getCmp('variablesAttributesPanel').add({xtype: 'combo',     id: variables[j].getTitle() + 'MinCombo', mode: 'local', valueField: 'value', displayField: 'value', store: operators,  width: 50,  x: 240, y: (j * 20 + 19), editable: false, allowBlank: false});

This is making the options in the dropdown list >, =, , !, <

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

音盲 2024-12-26 09:04:10

确保在组合框配置中设置了triggerAction

triggerAction : 'all'

var operators = new Array(">=",">","=~","x","!=","=","<","<=");

var test1 = new Ext.form.ComboBox({
    height:100,
    width:100,
    store: operators
});

var test2 = new Ext.form.ComboBox({
    height:100,
    width:100,
    triggerAction: 'all',
    store: operators
});

var win=new Ext.Window({
    renderTo:Ext.getBody(),
    items:[test1,test2],
    height:300,
    width:300,
    title:'comboWin'
}).show();

test1.setValue(operators[1]);
test2.setValue(operators[2]);

make sure triggerAction is set in combo box config

triggerAction : 'all'

var operators = new Array(">=",">","=~","x","!=","=","<","<=");

var test1 = new Ext.form.ComboBox({
    height:100,
    width:100,
    store: operators
});

var test2 = new Ext.form.ComboBox({
    height:100,
    width:100,
    triggerAction: 'all',
    store: operators
});

var win=new Ext.Window({
    renderTo:Ext.getBody(),
    items:[test1,test2],
    height:300,
    width:300,
    title:'comboWin'
}).show();

test1.setValue(operators[1]);
test2.setValue(operators[2]);
山有枢 2024-12-26 09:04:10

使用组合框的 setValue 方法。在这种情况下,显示和值是相同的,因此您可以只传递数组值:

comboBox.setValue(operators[0]); 

Use the setValue method of the combobox. In this case, the display and value are the same so you can just pass in the array value:

comboBox.setValue(operators[0]); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文