亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

基于KO+BootStrap+MVC實(shí)現(xiàn)的分頁(yè)控件代碼分享

 更新時(shí)間:2016年11月07日 10:30:06   作者:badnewfish  
本段js和html兩段代碼實(shí)現(xiàn)分頁(yè)控件效果,下面通過本文給大家詳細(xì)介紹下基于KO+BootStrap+MVC實(shí)現(xiàn)的分頁(yè)控件,非常不錯(cuò),感興趣的朋友一起看看吧

JS:

/// <reference path="../knockout-3.2.0.js" />
var ViewModel = function (data) {
var self = this;
self.ObjectList = ko.observableArray(data.ObjectList)
self.TotalCount = ko.observable(data.TotalCount);
self.PerCount = ko.observable(data.PerCount);
self.pageIndex = ko.observable(data.Index);
self.btns = ko.observableArray();
var getData = function (wantIndex) {
$.getJSON("/BaseInfor/GetList",
{
pageIndex: wantIndex, pageSize: self.PerCount()
},
function (data) {
self.ObjectList(data.ObjectList);
self.TotalCount(data.TotalCount);
self.PerCount(data.PerCount);
self.pageIndex(data.Index);
});
}
self.btnClick = function (item) {
getData(item);
}
self.perPageClick = function () {
var wantIndex = self.pageIndex() - 1;
if (wantIndex <= 0) return;
getData(wantIndex);
}
self.nextPageClick = function () {
var wantIndex = self.pageIndex() + 1;
if (wantIndex - 1 > (self.TotalCount() / self.PerCount())) return;
getData(wantIndex);
}
self.firstPageClick = function () {
getData(1);
}
self.lastPageClick = function () {
getData(self.pageTotal());
}
ko.computed(function () {
self.pageTotal = ko.observable(Math.ceil((self.TotalCount() / self.PerCount())))
var pageCount = self.pageTotal();
var start = (self.pageIndex() - 5) > 0 ? self.pageIndex() - 5 : 0;
var end = (start + 9) < pageCount ? start + 9 : pageCount;
if (end == pageCount)
{ var start = (pageCount - 9) > 0 ? pageCount - 9 : 0;; }
self.btns.removeAll();
for (var i = start; i < end; i++) {
self.btns.push(ko.mapping.fromJS(i + 1));
}
});
}
$(document).ready(function () {
$.getJSON("/BaseInfor/GetList",
{
pageIndex: 1, pageSize: 5
},
function (data) {
ko.applyBindings(new ViewModel(data));
});
});

HTML:

<table class="table table - striped">
<thead>
<tr>
<th>姓名</th>
<th>性別</th>
<th>出生年月</th>
<th>年齡</th>
<th>民族</th>
<th>身份證號(hào)</th>
<th>入黨時(shí)間</th>
<th>工作時(shí)間</th>
<th>籍貫</th>
<th>出生地</th>
<th>證件照</th>
</tr>
</thead>
<tbody>
<!-- ko foreach: ObjectList -->
<tr>
<td data-bind="text:Name"></td>
<td data-bind="text:Gender"></td>
<td data-bind="text:BirthDate"></td>
<td data-bind="text:Age"></td>
<td data-bind="text:Nation"></td>
<td data-bind="text:IDNumber"></td>
<td data-bind="text:PartyTime"></td>
<td data-bind="text:WorkTime"></td>
<td data-bind="text:hail"></td>
<td data-bind="text:BirthAddress"></td>
<td data-bind="text:Photo"></td>
</tr>
<!-- /ko -->
</tbody>
</table>
<div class="btn-toolbar" role="toolbar">
<div class="btn-group">
<input class="btn btn-success" type="button" value="<" data-bind="click:perPageClick" />
</div>
<div class="btn-group">
<input class="btn btn-success" type="button" data-bind="value:'1',click:firstPageClick" />
</div>
<div class="btn-group">
<!-- ko foreach: btns -->
<!-- ko if: $data==$parent.pageIndex() -->
<button class="btn btn-success" type="button" data-bind="text:$data,click:$parent.btnClick"></button>
<!-- /ko -->
<!-- ko ifnot: $data==$parent.pageIndex() -->
<button class="btn btn-default" type="button" data-bind="text:$data,click:$parent.btnClick"></button>
<!-- /ko -->
<!-- /ko -->
</div>
<div class="btn-group">
<input class="btn btn-success" type="button" data-bind="value:pageTotal,click:lastPageClick" />
</div>
<div class="btn-group">
<input class="btn btn-success" type="button" value=">" data-bind="click:nextPageClick" />
</div>
<div class="btn-group">
<span data-bind="text:TotalCount()+'條數(shù)據(jù)'" />
</div>
</div>
<script src="/Scripts/jquery-2.1.1.min.js"></script>
<script src="/Scripts/knockout-3.2.0.js"></script>
<script src="/Scripts/knockout.mapping.js"></script>
<script src="/Content/Plus/bootstrap-3.2.0-dist/js/bootstrap.min.js"></script>
<link href="/Content/Plus/bootstrap-3.2.0-dist/css/bootstrap.min.css" rel="stylesheet" />
<script src="/Scripts/BaseInfor/List.js"></script>

以上所述是小編給大家介紹的基于KO+BootStrap+MVC實(shí)現(xiàn)的分頁(yè)控件代碼分享,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • 分享19個(gè)JavaScript 有用的簡(jiǎn)寫寫法

    分享19個(gè)JavaScript 有用的簡(jiǎn)寫寫法

    最近很火的一篇來自國(guó)外的文章,js的簡(jiǎn)寫寫法一定程度上可以提高你的js書寫水平對(duì)于js的理解也會(huì)更近一步
    2017-07-07
  • JS實(shí)現(xiàn)的文字與圖片定時(shí)切換效果代碼

    JS實(shí)現(xiàn)的文字與圖片定時(shí)切換效果代碼

    這篇文章主要介紹了JS實(shí)現(xiàn)的文字與圖片定時(shí)切換效果代碼,可實(shí)現(xiàn)定時(shí)切換及鼠標(biāo)點(diǎn)擊切換兩種效果,涉及JavaScript鼠標(biāo)事件控制頁(yè)面樣式的相關(guān)技巧,需要的朋友可以參考下
    2015-10-10
  • 在Layui中實(shí)現(xiàn)開關(guān)按鈕的效果實(shí)例

    在Layui中實(shí)現(xiàn)開關(guān)按鈕的效果實(shí)例

    今天小編就為大家分享一篇在Layui中實(shí)現(xiàn)開關(guān)按鈕的效果實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-09-09
  • ES6 Object.assign()的用法及其使用

    ES6 Object.assign()的用法及其使用

    這篇文章主要介紹了ES6 Object.assign()的用法及其使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • javascript時(shí)間與時(shí)間戳互轉(zhuǎn)多種方式

    javascript時(shí)間與時(shí)間戳互轉(zhuǎn)多種方式

    javascript獲取時(shí)間、時(shí)間戳等,最核心的就是利用Date關(guān)鍵詞去獲取,時(shí)間戳的獲取方式整理了5種方法,后4種是利用new Date()實(shí)例化對(duì)象來獲取當(dāng)前時(shí)間,再對(duì)當(dāng)前獲取的時(shí)間再進(jìn)一步處理獲取時(shí)間戳,本文給大家介紹的非常詳細(xì),需要的朋友參考下吧
    2023-11-11
  • JavaScript使用readAsDataURL讀取圖像文件

    JavaScript使用readAsDataURL讀取圖像文件

    這篇文章主要為大家詳細(xì)介紹了JavaScript使用readAsDataURL讀取圖像文件的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • 深入理解js函數(shù)的作用域與this指向

    深入理解js函數(shù)的作用域與this指向

    下面小編就為大家?guī)硪黄钊肜斫鈐s函數(shù)的作用域與this指向。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-05-05
  • javascript文本框內(nèi)輸入文字倒計(jì)數(shù)的方法

    javascript文本框內(nèi)輸入文字倒計(jì)數(shù)的方法

    這篇文章主要介紹了javascript文本框內(nèi)輸入文字倒計(jì)數(shù)的方法,涉及javascript針對(duì)鍵盤事件的操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-02-02
  • js傳參數(shù)受特殊字符影響錯(cuò)誤的解決方法

    js傳參數(shù)受特殊字符影響錯(cuò)誤的解決方法

    js傳參數(shù)受特殊字符影響錯(cuò)誤,如果不做處理,會(huì)產(chǎn)品傳參錯(cuò)誤,encodeURI 方法返回一個(gè)編碼的URI,可以有效解決此問題,感興趣的朋友可以參考下
    2013-10-10
  • JS+CSS實(shí)現(xiàn)帶小三角指引的滑動(dòng)門效果

    JS+CSS實(shí)現(xiàn)帶小三角指引的滑動(dòng)門效果

    這篇文章主要介紹了JS+CSS實(shí)現(xiàn)帶小三角指引的滑動(dòng)門效果,可實(shí)現(xiàn)帶有箭頭提示效果的滑動(dòng)門功能,涉及JavaScript動(dòng)態(tài)操作頁(yè)面元素樣式的相關(guān)技巧,需要的朋友可以參考下
    2015-09-09

最新評(píng)論