【问题标题】:ExtJS 4 -grid selected cell colorExtJS 4 -grid 选定的单元格颜色
【发布时间】:2018-10-24 23:29:51
【问题描述】:

我试图找到这个问题的答案,但我找不到。所以我有简单的网格,通过插件(Ext.grid.plugin.CellEditing)编辑单元格。所以在这种情况下,我看到选定的单元格显示在“bluebox”中。

但我不想看到这样的选择,我想改变这个背景。请有任何建议。

谢谢 Jadhav,我在这个网格中看到了第二个问题。我只想编辑两列:

这个带有灰色背景的数字和这个复选框。第一个运行良好,但此复选框没有(当我选中它并转到其他位置时,选中的位置变为未选中)并且无法设置与我为带有数字的列设置的背景相同的背景。这是由以下人员完成的:

renderer: function(value, meta) {
          meta.style = "background-color:lightgray;";
      }    

这个方法,在复选框列给我这个:

为什么以及如何解决这个问题?


好的,由于您的帮助,几乎可以,但是当我通过 css 更改背景时,我看到以下结果(摘要行也是,部分是背景颜色),但仍然不知道为什么以及如何更正它:

【问题讨论】:

    标签: colors background grid extjs4 cell


    【解决方案1】:

    您可以对CellEditing 中的选定单元格使用css。

    在这个Fiddle中,我使用CellEditing插件创建了一个演示。

    代码sn-p:

    Ext.application({
        name: 'Fiddle',
    
        launch: function () {
            Ext.create('Ext.data.Store', {
                storeId: 'demostore',
                fields: ['name', 'email', 'phone'],
                data: [{
                    name: 'Lisa',
                    email: 'lisa@simpsons.com',
                    phone: '555-111-1224'
                }, {
                    name: 'Bart',
                    email: 'bart@simpsons.com',
                    phone: '555-222-1234'
                }, {
                    name: 'Homer',
                    email: 'homer@simpsons.com',
                    phone: '555-222-1244'
                }, {
                    name: 'Marge',
                    email: 'marge@simpsons.com',
                    phone: '555-222-1254'
                }]
            });
    
            Ext.create('Ext.grid.Panel', {
                title: 'Demo Data',
                store: 'demostore',
                cls:'my-grid',
                columns: [{
                    header: 'Name',
                    dataIndex: 'name',
                    editor: 'textfield'
                }, {
                    header: 'Email',
                    dataIndex: 'email',
                    flex: 1,
                    editor: {
                        xtype: 'textfield',
                        allowBlank: false
                    }
                }, {
                    header: 'Phone',
                    dataIndex: 'phone'
                }],
                selType: 'cellmodel',
                plugins: {
                    ptype: 'cellediting',
                    clicksToEdit: 1
                },
                height: 200,
                renderTo: Ext.getBody()
            });
        }
    });
    

    CSS

    <style>
        .my-grid .x-grid-cell-selected{
            background-color: transparent !important;
        }
    </style>
    

    您还使用单元格编辑器组件模糊事件的另一种方法。你需要把它放在代码下面

    var selectionModel = grid.getSelectionModel();
    selectionModel.deselect(selectionModel.selection.record)
    

    【讨论】:

      【解决方案2】:

      你只需要覆盖 inline css,这样你就可以改变背景颜色,即,

      .x-grid-row-selected .x-grid-td {
          background: #ffffff;
      }
      

      【讨论】:

      • 好的,我通过 css 更改了背景,但就像这样:“.x-status-cell .x-grid-cell-inner { background-color: lightgray !important; }” 并且在字段定义中:“ tdCls: 'x-status-cell',但是看新图,不知道为什么
      猜你喜欢
      • 1970-01-01
      • 2014-04-21
      • 2015-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多