廢話不多說,直接給大家貼代碼了,具體代碼如下所示:
$('#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復選框默認選中功能的實現代碼(從數據庫獲取到對應的狀態(tài)進行判斷是否為選中狀態(tài)),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
新聞熱點
疑難解答