【问题标题】:Change the background or class in table row更改表格行中的背景或类别
【发布时间】:2015-11-17 08:06:16
【问题描述】:

我用http://bootstrap-table.wenzhixin.net.cn/

需要一个例子说明如何在自定义字段值的函数中更改表格行的类

我将它用于单个单元格

cellStyle: function(value){
                    if(value=='0'){
                        return { classes: 'success' };
                    }else{
                        return { classes: 'danger' };
                    }               
                },

我明白了

但我需要这个

提前致谢

【问题讨论】:

  • rowStyle的样本
  • 你能给我一个例子,在 JavaScript 中改变“读取”字段的函数中的 rowStyle,基于这个github.com/wenzhixin/bootstrap-table/issues/221 for cellStyle
  • 我不太明白你的意思:在“Read”字段的函数中更改rowStyle?你能解释一下吗?
  • 你的意思是 - 检查单元格中的值 Read 并设置样式取决于它?
  • 是的,我就是这么想的

标签: javascript bootstrap-table


【解决方案1】:

rowStyle 函数中的第一个参数是当前行的数据对象。您可以在Read 列中简单地检查该输出的属性并返回所需的类。

function rowStyle(row, index) {

    if(row.Read = 100){ // possibly you map another property, it depends on your setting.

        return {classes : "neededClass" }
    }
    return {};
}

样本JS fiddle with test data

【讨论】:

    猜你喜欢
    • 2022-08-15
    • 2018-10-14
    • 2017-06-22
    • 2011-05-23
    • 1970-01-01
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多