国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

Bootstrap Table使用整理(五)之分頁組合查詢

2019-11-19 16:23:00
字體:
供稿:網(wǎng)友

推薦閱讀:

Bootstrap Table使用整理(一) //m.survivalescaperooms.com/article/115789.htm

Bootstrap Table使用整理(二)  //m.survivalescaperooms.com/article/115791.htm

Bootstrap Table使用整理(三)  //m.survivalescaperooms.com/article/115795.htm

Bootstrap Table使用整理(四)之工具欄 //m.survivalescaperooms.com/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ù)的值為空,則當(dāng)前參數(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ù)大家的。在此也非常感謝大家對武林網(wǎng)網(wǎng)站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 伊金霍洛旗| 抚宁县| 泰宁县| 游戏| 边坝县| 兴文县| 新沂市| 嵩明县| 万载县| 开鲁县| 波密县| 昔阳县| 冕宁县| 宁河县| 无为县| 广丰县| 措勤县| 武强县| 平山县| 沂水县| 中牟县| 泸定县| 呈贡县| 鸡西市| 庄浪县| 黄冈市| 崇阳县| 昭苏县| 南昌市| 无极县| 潢川县| 西贡区| 辉县市| 聂拉木县| 多伦县| 许昌县| 虹口区| 石楼县| 同德县| 荥经县| 阜平县|