BootStrap Table复选框默认选中功能的实现代码(从数据库获取到对应的状态进行判断是否为选中状态)

废话不多说,直接给大家贴代码了,具体代码如下所示:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$( '#table' ).bootstrapTable( 'destroy' );
$( '#table' ).bootstrapTable({
url: '../data/kehulist.json' ,
uniqueId: "id" ,
striped: true ,
// pagination:true,
clickToSelect: true ,
height:340,
   columns: [{
   field : 'state' ,
   checkbox: true ,
   formatter : stateFormatter
   },{
     field: 'id' ,   
     title: '组织编码' ,
     sortable: true ,
   },{
     field: 'name' ,
     title: '组织名称' ,
     sortable: true ,
   }],
});
//对应的函数进行判断;
function stateFormatter(value, row, index) {
   if (row.state == true )
     return {
       disabled : false , //设置是否可用
       checked : true //设置选中
     };
   return value;
}
模拟后台对应的数据;
[
  
     "id" : "1" ,
     "name" : "金蝶软件(中国)有限公司" ,
     "state" : false , //是否选中
     "tel" : "18536552258"
   },
   {
     "id" : "2" ,
     "name" : "金蝶软件(中国)有限公司" ,
     "state" : true ,
     "tel" : "18536552258"
   },
   {
     "id" : "3" ,
     "name" : "金蝶软件(中国)有限公司" ,
     "state" : false ,
     "tel" : "18536552258"
   }
]

以上所述是小编给大家介绍的BootStrap Table复选框默认选中功能的实现代码(从数据库获取到对应的状态进行判断是否为选中状态),希望对大家有所帮助。真是是棒棒!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值