【问题标题】:How to change background color of grid's dirty cells in Extjs如何在 Extjs 中更改网格脏单元格的背景颜色
【发布时间】:2014-06-27 12:33:11
【问题描述】:

我想更改网格中脏单元格的样式(背景颜色...等)。如何应用只影响网格的污垢单元的样式?

【问题讨论】:

    标签: extjs grid styling cells


    【解决方案1】:

    使用以下 CSS 类名来更改脏单元格的某些属性:

    .x-grid3-dirty-cell {
         background-image:none;
    }
    

    这将删除脏单元格中的红色角。这是适用的 ExtJs 版本>=3

    如果你想改变单元格的背景颜色,你必须使用x-grid3-cell-inner 您可以使用columnRenderer,您可以在其中编写逻辑。编辑单元格时,将调用 columnrenderer,您可以在其中检查值是否更改,使用

    更改颜色
    function columnrenderer(value, meta,records,rowIndex,colIndex,store,view){
        var column = view.getHeaderAtIndex(colIndex);
        var dataIndex = column.dataIndex;
        records.modified[dataIndex]; //Will give the original value
        value; //gives the changed value
        if(//both are not same)
             return '<div class="x-grid3-cell" style="background-color:red;"><span >(' + value + ')</span></div>';
        else
           //do nothing
    }
    

    有关 GridCellRenderer 的更多信息,请参阅ExtJs Grid FAQ

    【讨论】:

    • 任何包含css 文件的文件夹。在那个 css 文件中,放置这些类。请参阅index.html 中的 css 文件。这是 ExtJs 框架使用的类名。它将被覆盖。
    • 添加到css文件仍然没有变化
    猜你喜欢
    • 1970-01-01
    • 2011-12-23
    • 2016-03-10
    • 1970-01-01
    • 1970-01-01
    • 2020-04-28
    • 1970-01-01
    • 2021-01-04
    • 1970-01-01
    相关资源
    最近更新 更多