推薦閱讀:
創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比尚義網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式尚義網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋尚義地區(qū)。費(fèi)用合理售后完善,十載實(shí)體公司更值得信賴。
Bootstrap Table使用整理(一) https://www.jb51.net/article/115789.htm
Bootstrap Table使用整理(二) https://www.jb51.net/article/115791.htm
Bootstrap Table使用整理(三) https://www.jb51.net/article/115795.htm
Bootstrap Table使用整理(四)之工具欄 https://www.jb51.net/article/115798.htm
一、分頁(yè)組合查詢
/*
* data-pagination 指定是否啟用分頁(yè)
* data-page-list 指定分頁(yè)的頁(yè)數(shù)據(jù)量數(shù)組 '[5,10]'
* data-side-pagination 指定分頁(yè)是否是服務(wù)端(server)/客戶端(client)
* 特別說(shuō)明:
* 客戶端,請(qǐng)求參數(shù):
* search:文本框內(nèi)容,在文本框內(nèi)容改變是自動(dòng)提交請(qǐng)求
* order: 排序方式
* sort:排序列名
* offset:劃過(guò)條數(shù)
* limit:要獲取的數(shù)據(jù)的條數(shù)
*
*/
var $table1= $('#table1').bootstrapTable({
columns: [
{ field: 'sno', title: '學(xué)生編號(hào)',sortable:true },
{ field: 'sname', title: '學(xué)生姓名' },
{ field: 'ssex', title: '性別' },
{ field: 'sbirthday', title: '生日' },
{ field: 'class', title: '課程編號(hào)' },
],
url: '@Url.Action("GetStuList", "DataOne")',
pagination: true,
sidePagination: 'server',
pageList:[5,10,20,50],
queryParams: function (params) {
params.name = '張三豐';
//特別說(shuō)明,返回的參數(shù)的值為空,則當(dāng)前參數(shù)不會(huì)發(fā)送到服務(wù)器端
//這種指定請(qǐng)求參數(shù)的方式和datatables控價(jià)類似
params.sex = $('input[name="sex"]:checked').val();
return params;
}
});
//刷新方法
$('#heartBtn').click(function () {
$table1.bootstrapTable('refresh');
});
[html] view plain copy print?
<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> 2.服務(wù)端代碼處理
public JsonResult GetStuList(string sex, string search, string sort, string order, int offset, int limit)
{
var query = _Context.Student.AsQueryable();
if (string.IsNullOrEmpty(sex) == false)
query = query.Where(q => q.Ssex == sex);
if (string.IsNullOrEmpty(search) == false)
query = query.Where(q => q.Sno.Contains(search) || q.Sname.Contains(search));
//排序
if (sort == "sno")
{
if (order == "asc")
query = query.OrderBy(q => q.Sno);
else
query = query.OrderByDescending(q => q.Sno);
}
else
query = query.OrderBy(q => q.Sbirthday);
int total = query.Count();
var list = query.Skip(offset).Take(limit).ToList();
return Json(new
{
rows = list,
total = total
});
}
以上所述是小編給大家介紹的Bootstrap Table使用整理(五)之分頁(yè)組合查詢,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)創(chuàng)新互聯(lián)網(wǎng)站的支持!
當(dāng)前名稱:BootstrapTable使用整理(五)之分頁(yè)組合查詢
URL分享:http://chinadenli.net/article10/geshdo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、網(wǎng)站營(yíng)銷、微信小程序、微信公眾號(hào)、網(wǎng)站導(dǎo)航、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)