溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Bootstrap中Table使用整理之工具欄的示例分析

發(fā)布時(shí)間:2021-08-09 14:12:18 來源:億速云 閱讀:165 作者:小新 欄目:web開發(fā)

這篇文章將為大家詳細(xì)講解有關(guān)Bootstrap中Table使用整理之工具欄的示例分析,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

一、啟用默認(rèn)支持的工具欄

/* 
* data-search 是否顯示搜索框 
* data-show-refresh 是否像是刷新按鈕,注:刷新操作會重新請求數(shù)據(jù),并帶著請求參數(shù) 
* data-show-toggle 是否顯示面板切換按鈕 
* data-show-columns 是否顯示列控制按鈕 
*/ 
$('#table1').bootstrapTable({ 
 columns: [ 
 { field: 'sno', title: '學(xué)生編號' }, 
 { field: 'sname', title: '學(xué)生姓名' }, 
 { field: 'ssex', title: '性別' }, 
 { field: 'sbirthday', title: '生日' }, 
 { field: 'class', title: '課程編號' }, 
 ], 
 url:'@Url.Action("GetStudent","DataOne")' 
}); 
<table id="table1" 
 data-classes="table table-hover " 
 data-search="true" 
 data-show-refresh="true" 
 data-show-toggle="true" 
 data-show-columns="true"></table>

Bootstrap中Table使用整理之工具欄的示例分析

二、擴(kuò)展工具欄使用

/* 
* data-toolbar 用于指定id的div擴(kuò)展工具欄,這種方式類似EaseUI中的datagird 
* queryParams 請求服務(wù)器數(shù)據(jù)時(shí),你可以通過重寫參數(shù)的方式添加一些額外的參數(shù),例如 toolbar 中的參數(shù) 如果 queryParamsType = 'limit' ,返回參數(shù)必須包含 
  limit, offset, search, sort, order 否則, 需要包含: 
  pageSize, pageNumber, searchText, sortName, sortOrder. 
  返回false將會終止請求 
*/ 
var $table1= $('#table1').bootstrapTable({ 
 columns: [ 
 { field: 'sno', title: '學(xué)生編號' }, 
 { field: 'sname', title: '學(xué)生姓名' }, 
 { field: 'ssex', title: '性別' }, 
 { field: 'sbirthday', title: '生日' }, 
 { field: 'class', title: '課程編號' }, 
 ], 
 url: '@Url.Action("GetStudent","DataOne")', 
 queryParams: function (params) { 
 params.name = '張三豐'; 
 //特別說明,返回的參數(shù)的值為空,則當(dāng)前參數(shù)不會發(fā)送到服務(wù)器端 
 params.sex = $('input[name="sex"]:checked').val(); 
 return params; 
 } 
}); 
//刷新方法 
$('#heartBtn').click(function () { 
 ////刷新處理,指定query 的參數(shù),注:此地方指定的參數(shù),僅在當(dāng)次刷新時(shí)使用 
 //$table1.bootstrapTable('refresh', { 
 // query: { 
 // name: '張三' 
 // } 
 //}); 
 $table1.bootstrapTable('refresh'); 
}); 
<table id="table1" 
 data-classes="table table-hover " 
 data-search="true" 
 data-show-refresh="true" 
 data-show-toggle="true" 
 data-show-columns="true" 
 data-toolbar="#toolbar"></table> 
<div id="toolbar"> 
 <div class="btn-group"> 
 <button class="btn btn-default"> 
  <i class="glyphicon glyphicon-plus"></i> 
 </button> 
 <button class="btn btn-default"> 
  <i class="glyphicon glyphicon-heart" id="heartBtn"></i> 
 </button> 
 <button class="btn btn-default"> 
  <i class="glyphicon glyphicon-trash"></i> 
 </button> 
 </div> 
 <div class="form-group"> 
 <label class="control-label">性別:</label> 
 <label class="radio-inline"> 
  <input type="radio" name="sex" value="男" /> 男 
 </label> 
 <label class="radio-inline"> 
  <input type="radio" name="sex" value="女" /> 女 
 </label> 
 </div> 
</div>

Bootstrap中Table使用整理之工具欄的示例分析

關(guān)于“Bootstrap中Table使用整理之工具欄的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI