简体   繁体   English

组合中的默认值不可见-extjs

[英]Default value in combo not visible - extjs

I have grid.Panel in my extjs page. 我的extjs页面中有grid.Panel。 There are comboboxes in the grid. 网格中有组合框。 On load of the page, the combobox doesn't appear like combobox. 在页面加载时,组合框看起来不像组合框。 Instead they look like empty cell. 相反,它们看起来像是空单元格。 On click of the cell, they reveal the dropdown box like symbol. 单击该单元格后,它们会显示下拉框,如符号。

var decisionComboStore = new Ext.data.ArrayStore({
   fields: ['abbr', 'action'],
   data : [
           ['proceed', 'Proceed'],
           ['upNotDone', 'Upload Not Done']
          ]
    });
var stockAuditGrid = Ext.create('Ext.grid.Panel', {
    {header: '<center><b>Decision</center>',  dataIndex: 'decision', flex:1,
        editor: {
            xtype:'combo',
                    store: decisionComboStore,
                            id: 'decisionCombo',
                           displayField:'action',
                           valueField: 'abbr',
                           mode: 'local',
                          typeAhead: false,
                emptyText: 'Select...',
            allowBlank:false
        },sortable: false, hideable: false}
 });

I don't know what else I should add to make it look like a combo box on load of the document. 我不知道我还要添加什么以使其看起来像一个加载文档的组合框。 Also the box should display the default value. 此外,该框应显示默认值。

You expect something that cannot happen. 您期望不会发生的事情。 Editors in an Ext grid are activated only on (dbl) click and there is always only one active at a time. 只有单击(dbl)才能激活Ext网格中的编辑器,并且一次始终只有一个处于活动状态。

If are fine with this behavior but you need only appearance of combos then you must use css to style the grid cells. 如果此行为很好,但仅需要显示连击,则必须使用CSS设置网格单元的样式。

You can't make it look like a combo box easily. 您不能轻易使其看起来像一个组合框。

But you can use a custom renderer on the grid column to show Select... when the record's field is empty, without actually modifying the underlying data in the store: 但是,当记录的字段为空时,可以在网格列上使用自定义渲染器以显示Select... ,而无需实际修改存储中的基础数据:

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.column.Column-cfg-renderer http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.column.Column-cfg-renderer

Example: 例:

renderer:function(value,meta) {
    if(value === undefined || value === null || value === "") {
        meta.style="color:#666"
        return "&lt;Select...&gt;";
    }
    return value;
}

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

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