BootStrapTable 單選及取值的實(shí)現(xiàn)方法
學(xué)習(xí)bootstrapTable 一直沒有找到 單選框的選定的和取值的教程,今天寫一個(gè).作為筆記
1. 效果圖: 點(diǎn)擊 bootstrapTable 單選的按鈕, 選中該列, 取到該列的所有值.

2. js 代碼 : bootstrapTable 初始化
a. 注意:
singleSelect : true, // 單選checkbox
columns : [ { checkbox: true } ] // bootstrapTable 顯示單選checkbox 列
$().ready(function() {
// bootstrapTable 表格數(shù)據(jù)初始化
var table = $('#item_info_table').bootstrapTable({
url : '<c:url value='/item/entry/main_info/list_data'/>',
method : 'POST', // GET
uniqueId : 'id', // 綁定ID
toolbar : '#item_info_toolbar', // 搜索框綁定
search : true, // 搜索框
pagination : true, // 顯示頁碼等信息
singleSelect : true, // 單選checkbox
showRefresh : true, // 顯示刷新按鈕
showColumns : true, // 選擇顯示的列
pageSize : pageSize, // 當(dāng)前分頁值
pageList : pageList, // 分頁選頁
dataType : dataType, // JSON
sidePagination : sidePagination, // 服務(wù)端請(qǐng)求
buttonsAlign : buttonsAlign, // 刷新,顯示列按鈕位置
toolbarAlign : toolbarAlign, // 搜索框位置
columns : [
{
checkbox: true
}, {
title : '項(xiàng)目序號(hào)',
field : 'itemNum',
align : 'center',
formatter:function(value,row,index){
var url = '';
if (isSingleItem(value)) url = '<a href="#" mce_href="#" onclick="single_item_edit_fun(\'' + row.infoId + '\')">' + row.itemNum + '</a> ';
if (isJoinItem(value)) url = '<a href="#" mce_href="#" onclick="join_item_edit_fun(\'' + row.infoId + '\')">' + row.itemNum + '</a> ';
return url;
}
}, {
title : '項(xiàng)目名稱',
field : 'itemName',
align : 'center'
}
]
});
/********** bootstrapTable toolbar 按鈕事件 *********/
// [新增] 按鈕點(diǎn)擊事件
$('#item_info_btn_add').click(function(){
$('#item_info_modal').modal('show');
});
// [項(xiàng)目立項(xiàng)] 按鈕點(diǎn)擊事件
$('#item_info_btn_do').click(function(){
var selectContent = table.bootstrapTable('getSelections')[0];
if(typeof(selectContent) == 'undefined') {
toastr.warning('請(qǐng)選擇一列數(shù)據(jù)!');
return false;
}else{
console.info(selectContent);
$('#item_project_modal').modal('show'); // 項(xiàng)目立項(xiàng)面板
}
});
});
3. bootstrapTable url : '<c:url value='/item/entry/main_info/list_data'/>', 后臺(tái)json數(shù)據(jù)
注意. 第一個(gè)圖片中的 chrome F12 中的 Object 就是selectContent =table.bootstrapTable('getSelections')[0] 中的數(shù)據(jù)了 這樣我們就能取到 bootstrap 單選框 選擇 一行的 數(shù)據(jù).
{
"offset":10,
"rows":
[
{
"infoId":"main_info_1111",
"itemName":"AAA項(xiàng)目組",
"itemNum":"JXY160909011S"
},
{
"infoId":"main_info_2222",
"itemName":"BBB項(xiàng)目組",
"itemNum":"JXY160909012F"
}
],
"total":10
}
以上所述是小編給大家介紹的BootStrapTable 單選及取值的實(shí)現(xiàn)方法,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- Bootstrap標(biāo)簽頁(Tab)插件使用方法
- 簡(jiǎn)單實(shí)現(xiàn)Bootstrap標(biāo)簽頁
- BootStrap框架個(gè)人總結(jié)(bootstrap框架、導(dǎo)航條、下拉菜單、輪播廣告carousel、柵格系統(tǒng)布局、標(biāo)簽頁tabs、模態(tài)框、菜單定位)
- Bootstrap每天必學(xué)之標(biāo)簽頁(Tab)插件
- bootstrap table 數(shù)據(jù)表格行內(nèi)修改的實(shí)現(xiàn)代碼
- bootstrap jquery dataTable 異步ajax刷新表格數(shù)據(jù)的實(shí)現(xiàn)方法
- bootstrap table配置參數(shù)例子
- Bootstrap table兩種分頁示例
- 基于Bootstrap的標(biāo)簽頁組件及bootstrap-tab使用說明
相關(guān)文章
javascript實(shí)現(xiàn)日期格式轉(zhuǎn)換
這篇文章主要介紹了javascript實(shí)現(xiàn)日期格式轉(zhuǎn)換,非常的簡(jiǎn)單實(shí)用,項(xiàng)目中經(jīng)常可以用到,這里推薦給大家2014-12-12
javascript 中事件冒泡和事件捕獲機(jī)制的詳解
這篇文章主要介紹了javascript 中事件冒泡和事件捕獲機(jī)制的詳解的相關(guān)資料,網(wǎng)上的相關(guān)資料有很多,但是講的不是多清楚,通過本文希望能讓大家理解掌握,需要的朋友可以參考下2017-09-09
詳解微信小程序-獲取用戶session_key,openid,unionid - 后端為nodejs
這篇文章主要介紹了微信小程序獲取session_key,openid,unionid的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04

