Twitter bootstrap 细胞颜色-温致新';s引导表(或备选方案)

Twitter bootstrap 细胞颜色-温致新';s引导表(或备选方案),twitter-bootstrap,bootstrap-4,bootstrap-table,Twitter Bootstrap,Bootstrap 4,Bootstrap Table,我使用wenzhixin的引导表已经有一段时间了,效果非常好,现在我需要根据不同的阈值对每个单元格进行着色,我想通过ajax返回单元格值和单元格颜色,这样我就可以完成调用中的所有过程。 我正在加载表格,如下所示: if (data) { $('#estado').bootstrapTable('removeAll'); $('#estado').bootstrapTable('load', data); } 你建议如何解决这个问题,也许我不应该用文之心bt来解决这个问题 我看到

我使用wenzhixin的引导表已经有一段时间了,效果非常好,现在我需要根据不同的阈值对每个单元格进行着色,我想通过ajax返回单元格值和单元格颜色,这样我就可以完成调用中的所有过程。 我正在加载表格,如下所示:

if (data) {
    $('#estado').bootstrapTable('removeAll');
    $('#estado').bootstrapTable('load', data);
}
你建议如何解决这个问题,也许我不应该用文之心bt来解决这个问题

我看到了另一个答案,但为了使用它们,我应该添加一个额外的列,其中包含下一个应该具有的值,然后通过js对其进行着色,这是最好的方法吗?
谢谢大家!

引导表应该能够处理您想要的内容。基于单元的样式有三个选项:

  • 使用“rowStyle”表格选项设置行样式,该选项启用表格行的CSS样式。这将使用类似这样的函数从行数据派生行样式:

    function rowStyle(row, index) {
      return {
        classes: 'text-nowrap another-class',
        css: {"color": "blue", "font-size": "50px"}
      };
    }
    
    function cellStyle(value, row, index, field) {
      return {
        classes: 'text-nowrap another-class',
        css: {"color": "blue", "font-size": "50px"}
      };
    }
    
  • 使用“cellStyle”列选项设置单元格样式,该选项启用表格单元格的CSS样式。这将使用类似这样的函数从行数据中导出单元格样式:

    function rowStyle(row, index) {
      return {
        classes: 'text-nowrap another-class',
        css: {"color": "blue", "font-size": "50px"}
      };
    }
    
    function cellStyle(value, row, index, field) {
      return {
        classes: 'text-nowrap another-class',
        css: {"color": "blue", "font-size": "50px"}
      };
    }
    
    请参阅完整示例

  • 使用“formatter”列选项设置单个字段格式,该选项提供单元格内容的自定义HTML格式。这将使用类似这样的函数来派生表格单元格的HTML内容:

    function priceFormatter(value) {
       // 16777215 == ffffff in decimal
       var color = '#'+Math.floor(Math.random() * 6777215).toString(16);
       return '<div  style="color: ' + color + '">' +
              '<i class="glyphicon glyphicon-usd"></i>' +
              value.substring(1) +
              '</div>';
    }
    
    函数价格格式化程序(值){
    //16777215==十进制FFFF
    var color='#'+Math.floor(Math.random()*6777215).toString(16);
    返回“”+
    '' +
    值。子字符串(1)+
    '';
    }
    
    请参阅完整示例


  • 引导表应该能够处理您想要的内容。基于单元的样式有三个选项:

  • 使用“rowStyle”表格选项设置行样式,该选项启用表格行的CSS样式。这将使用类似这样的函数从行数据派生行样式:

    function rowStyle(row, index) {
      return {
        classes: 'text-nowrap another-class',
        css: {"color": "blue", "font-size": "50px"}
      };
    }
    
    function cellStyle(value, row, index, field) {
      return {
        classes: 'text-nowrap another-class',
        css: {"color": "blue", "font-size": "50px"}
      };
    }
    
  • 使用“cellStyle”列选项设置单元格样式,该选项启用表格单元格的CSS样式。这将使用类似这样的函数从行数据中导出单元格样式:

    function rowStyle(row, index) {
      return {
        classes: 'text-nowrap another-class',
        css: {"color": "blue", "font-size": "50px"}
      };
    }
    
    function cellStyle(value, row, index, field) {
      return {
        classes: 'text-nowrap another-class',
        css: {"color": "blue", "font-size": "50px"}
      };
    }
    
    请参阅完整示例

  • 使用“formatter”列选项设置单个字段格式,该选项提供单元格内容的自定义HTML格式。这将使用类似这样的函数来派生表格单元格的HTML内容:

    function priceFormatter(value) {
       // 16777215 == ffffff in decimal
       var color = '#'+Math.floor(Math.random() * 6777215).toString(16);
       return '<div  style="color: ' + color + '">' +
              '<i class="glyphicon glyphicon-usd"></i>' +
              value.substring(1) +
              '</div>';
    }
    
    函数价格格式化程序(值){
    //16777215==十进制FFFF
    var color='#'+Math.floor(Math.random()*6777215).toString(16);
    返回“”+
    '' +
    值。子字符串(1)+
    '';
    }
    
    请参阅完整示例


  • 你所说的“不同阈值”是什么意思?例如:如果client_id=1和salesSo,假设你每行有3个值:
    client_id
    sales
    ,例如
    sales_target
    ,颜色取决于
    sales
    sales_target
    之间的关系。你说得对吗“不同的门槛“?例如:如果client_id=1且salesSo,假设您每行有3个值:
    client_id
    sales
    ,例如
    sales\u target
    ,颜色取决于
    sales
    sales\u target
    我说得对吗?@Alejandro,这个答案有用吗?@Alejandro,这个答案有用吗?”?