【问题标题】:ReadOnly combobox in ExtjsExtjs 中的只读组合框
【发布时间】:2015-02-24 06:36:41
【问题描述】:

我试图在 Extjs 中有一个组合框,这样用户不应该编辑已经可用的默认值:

这是我尝试过的代码:::

Ext.onReady(function () {
var states = Ext.create('Ext.data.Store', {
    fields: ['abbr', 'name'],

    data: [{
        "abbr": "AL",
        "name": "Alabama"
    }, {
        "abbr": "AK",
        "name": "Alaska"
    }, {
        "abbr": "AZ",
        "name": "Arizona"
    }]
});

Ext.create('Ext.form.ComboBox', {
    fieldLabel: 'Choose State',
    store: states,
    editable:false,
    queryMode: 'local',
    valueField: 'abbr',
    renderTo: Ext.getBody(),
    // Template for the dropdown menu.
    // Note the use of "x-boundlist-item" class,
    // this is required to make the items selectable.
    tpl: Ext.create('Ext.XTemplate', '<tpl for=".">', '<div class="x-boundlist-item">{abbr} - {name}</div>', '</tpl>'),
    // template for the content inside text field
    displayTpl: Ext.create('Ext.XTemplate', '<tpl for=".">', '{abbr} - {name}', '</tpl>')
}); 
});

虽然我做了 editable:false ... 但它没有用。 请帮忙。

【问题讨论】:

    标签: extjs extjs4 extjs4.1 extjs4.2


    【解决方案1】:

    由于一些缓存问题,editable:false 不起作用

    然而这是正确的解决方案

    【讨论】:

      猜你喜欢
      • 2010-09-14
      • 1970-01-01
      • 1970-01-01
      • 2011-08-19
      • 1970-01-01
      • 2012-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多