SpringBoot 十四 列表的多彩格式化显示

6-11 列表的多彩格式化显示
Bootstrap Table的官方在线帮助:https://bootstrap-table.com/docs/api/table-options/
通过该网址 要啥有啥在这里插入图片描述
一处为格式名称 需要那个格式直接在JS内 或者html主页添加 二处则为 格式具体参数 用那个直接用
左上角view source 就是看源码 并且还可以跟普通的 bg-success 等bootstrap 默认元素 混合使用
主要讲了TheadClasses 表头格式 TableClasses 表格格式 RowStyle 整行格式 (可以放在同一function 内 也可以单独定义function)
在这里插入图片描述

https://hackerthemes.com/bootstrap-cheatsheet/#collapse 普通的bootstrap 就用这个
或者用这个后台模板的 https://colorlib.com/polygon/gentelella/index.html
Bootstrap-Table组件能够进行丰富多彩的格式化显示,主要包括下面几个方面
1.启用Bootstrap的Table样式;
classes:“table table-bordered table-hover table-dark”,//启用bootstrap的表格样式
直接在方法内加

2.表头的背景色;
直接在方法内加
theadClasses: “bg-success”, //表头的背景色

3.根据行中列的值动态对整行的文字及背景颜色进行设置;(可以放在同一function 内 也可以单独定义function)
管中窥豹 可见一斑
即可通过IF return 返回要显示的值 注意css和classes 的格式
还可通过常量rowStyle 、 row 程序自带 和 row.employeenumber 只要创建了就自带 进行设置 并且 row.employeenumber 这个是自动循环设置某一行
每个条件语句之后 必用{} 括号 括起来 return 和css 后边的语句都需要{}括起来
index 为每一行的索引
rowStyle: function (row,index){
if (row.employeenumber<33)
{
return {
css:{color:‘blue’}, //本行文字颜色(自定义)
classes: ‘bg-warning’// 本行背景颜色 (bootstrap 格式)
};
}
else if (row.employeenumber>35){//利用bootstrap颜色体系
return {css:{background:’#e5a028’}};//本行背景颜色(自定义)

        }
        else {// 保持原色彩
            return {}
            // 千万不要忘了else  不然如果有不符合条件的就显示失误了
        }
            },

4.对整列的文本进行格式化显示;

{
field: ‘comstatus’,
title: ‘运营状态’,
formatter: function indexFormatter(value, row, index){
var newValue="";
if (value==“开业”){newValue=’’+value+’’;}
else if (value==“未开业”){newValue=’’+value+’’}
else {newValue =’’+value+’’}
return newValue;
}
}
此处方法名 indexFormatter 为摆设 不具备实质性作用

    自己分析  rowStyle 属性返回的都是style  即便用class 用的也是classes:‘ ’  
    而对字段属性进行formatter  则可以混合着用   返回的是字符串   一般还在字符串内加上value的值  var 	newValue=   '<span class="badge bg-blue">'+value+'</span>'   return newValue 

以下为仿照字段 {
field: ‘comname’,
title: ‘公司名称’,
formatter:function (value,row,index){
return ‘超级无敌’+value;

        }
        灵活运用 value, row, index  值 行 列

5.对单元格的文本和背景进行格式化显示;
单元格格式修改函数 还是在字段内使用
cellStyle:function (value,row,index){
if (value==‘666’) return {css:{background:’#89ffb7’}}
else return value;

        }

6.灵活的采用Bootstrap的样式和自定义样式进行文本显示

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值