【问题标题】:Is there any way to create column filters based on background color of cells in the grid有没有办法根据网格中单元格的背景颜色创建列过滤器
【发布时间】:2019-04-22 16:20:28
【问题描述】:

我是 extjs 的新手,需要在网格中创建一个过滤器,它可以根据单元格的背景颜色过滤列。我已经根据需要在单元格上设置了背景颜色,但找不到任何东西来创建可以根据背景颜色过滤列的过滤器。

我尝试了 List 过滤器,但它只支持单元格内的值,而不支持 cells 的背景颜色。

这是创建具有背景颜色的单元格的代码:

renderer : function(value, meta) {
    if(parseInt(value) > 0) {
        meta.style = "background-color:green;";
    } else {
        meta.style = "background-color:red;";
    }
    return value;
}

【问题讨论】:

    标签: extjs extjs4


    【解决方案1】:

    您不能根据单元格背景颜色添加过滤器。

    您应该按参数过滤。您可以在模型中添加新参数,如color,并使用convert 函数将值设置为基于其他列值的颜色。

    看例如。

    {
         name: 'color',
         convert: function (v, rec) {
             return rec.get('otherParam') > 0 ? 'green' : 'red';
         },
         depends: ['otherParam']
     }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-08
      • 2010-09-25
      • 2020-01-23
      • 2015-07-11
      • 1970-01-01
      • 1970-01-01
      • 2011-04-03
      相关资源
      最近更新 更多