bootstrap-table官方文档
https://bootstrap-table.com/docs/api/table-options/

cellSytle:
bootstrap-table妙用
*指定单元格的样式

//省略部分代码
{
   title: '名称',
    field: 'name',
    align: 'center',
    valign: 'middle',
    width: 80,
    cellStyle: function cellStyle(value, row, index) {
        return {
            css: {
                "max-width": "200px"
            }
        };
    }
}

formatter:
bootstrap-table妙用
**可转换表中数据格式

//省略部分代码
{
    title: '是否运行',
    field: 'isRun',
    sortable: true,
    valign: 'middle',
    align: 'center',
    formatter: function(value, row, index) {
          var isRun;
          if (value == "运行") {
              isRun = "是";
          } else {
              isRun = "否";
          }
          return isRun;
      }
 }

events:
bootstrap-table妙用
**设置单元格的事件监听器

//省略部分代码
 {
     title: 'xxxx',
     field: 'xxxxxx',
     valign: 'middle',
     formatter: function(value, row, index) {
         return "<a href='javascript:void(0)' class=\"viewDetails\">" + value + "</a>";
     },
     events: {
         'click .viewDetails': function (e, value, row,dataStr) {
             showModalDetail(row,dataStr);
         }
     }
 }

相关文章: