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