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 () {
         ;
         ) return;
         getData(wantIndex);
     }
     self.nextPageClick = function () {
         ;
          > (self.TotalCount() / self.PerCount())) return;
         getData(wantIndex);
     }
     self.firstPageClick = function () {
         getData();
     }
     self.lastPageClick = function () {
         getData(self.pageTotal());
     }

     ko.computed(function () {
         self.pageTotal = ko.observable(Math.ceil((self.TotalCount() / self.PerCount())))
         var pageCount = self.pageTotal();
         ) >  ? self.pageIndex() -  : ;
         ) < pageCount ? start +  : pageCount;
         if (end == pageCount)
         { ) >  ? pageCount -  : ;; }
         self.btns.removeAll();
         for (var i = start; i < end; i++) {
             self.btns.push(ko.mapping.fromJS(i + ));
         }
     });
 }
 $(document).ready(function () {
     $.getJSON("/BaseInfor/GetList",
          {
              pageIndex: , pageSize:
          },
         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>身份证号</th>
             <th>入党时间</th>
             <th>工作时间</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()+'条数据'" />
     </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的分页控件的更多相关文章

  1. 基于存储过程的MVC开源分页控件--LYB.NET.SPPager

    摘要 现在基于ASP.NET MVC的分页控件我想大家都不陌生了,百度一下一大箩筐.其中有不少精品,陕北吴旗娃杨涛大哥做的分页控件MVCPager(http://www.webdiyer.com/)算 ...

  2. 基于存储过程的MVC开源分页控件

    基于存储过程的MVC开源分页控件--LYB.NET.SPPager 摘要 现在基于ASP.NET MVC的分页控件我想大家都不陌生了,百度一下一大箩筐.其中有不少精品,陕北吴旗娃杨涛大哥做的分页控件M ...

  3. 一个Bootstrap风格的分页控件

      http://www.cnblogs.com/wangwei123/p/3682626.html 主题 jQueryBootstrap 一个Bootstrap风格的分页控件,对于喜欢Bootstr ...

  4. Mvc自定义分页控件

    MVC开发分页常常使用第三方控件,生成的分页HTML带有版权申明,虽然免费,但是总有的别扭.于是,某日,楼主闲来蛋疼,折腾了个自定义分页控件: 先来展示下效果图: 1>当分页不超过10页的时候, ...

  5. Net MVC轻量级分页控件

    JPager.Net MVC超好用轻量级分页控件   JPager.Net  MVC好用的轻量级分页控件,好用到你无法想象,轻量到你无法想象. JPager.Net  MVC好用的轻量级分页控件,实现 ...

  6. 基于jquery扩展漂亮的分页控件(ajax)

    分页控件式大家在熟悉不过的控件,很多情况下都需要使用到分页控件来完成列表数据加载操作,在很多分页控件中有的编写麻烦,有的应用扩展比较复杂,有的分页控件样式比较丑陋,有的分页控件用户体验操作比较简单等等 ...

  7. bootstrap-datetimepicker:基于twitter bootstrap的日期/时间选择控件

    bootstrap-datetimepicker是一个基于twitter bootstrap的简单日期/时间选择控件. <!DOCTYPE HTML> <html> <h ...

  8. 基于C#语言MVC框架NPOI控件导出Excel表数据

    控件bin文件下载地址:https://download.csdn.net/download/u012949335/10610726@{ ViewBag.Title = "dcxx" ...

  9. MVC Page分页控件

    MVCPage帮助类 控制器代码 public ActionResult Article(int? page) { //Session["ArticleClass"] = cont ...

随机推荐

  1. Music Review

    (What do you want to do?)(What do you want to do?)(What do you want to do?)(What is the meaning of l ...

  2. 初学jquery,自己写的一个jquery幻灯片,代码有些笨拙,希望有大神可以指点一二,精简一下代码

    html代码 <div class="picCon"> <div class="bigPic"> <ul> <li c ...

  3. CSS中!important的优先级

    本篇文章使用最新的IE10以及firefox与chrome测试(截止2013年5月27日22:23:22) CSS的原理: 我们知道,CSS写在不同的地方有不同的优先级, .css文件中的定义 < ...

  4. &与&&的区别

    &是“逻辑与”(“按位与”“位运算符”),一定要判断完所有的条件才能确定到底返回true还是false. &&是“短路与”(“逻辑运算符”),当从左至右判断时,一旦出现有一个条 ...

  5. Minimum Path Sum [LeetCode]

    Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...

  6. ShopNc基本介绍

    ShopNc学习笔记: 1.shopNc每个文件夹定义了单入口文件eg:shopnc/admin/index.php, shopnc/cms/index.php 2.MVC M: $model = M ...

  7. LaTeX自学ing

    恩看标题嘛...Xs要自学LaTeX的说! 话说cnblogs不支持插入LaTeX格式的代码的说?..唔~ 嘛...首先是些简单的东西(像是文件的格式啦,作者啦之类的): (注意:\documentc ...

  8. MVN使用随笔

    001 创建项目 mvn archetype:generate -DgroupId=com.company.push.monitor -DartifactId=push-monitor -Darche ...

  9. Svn常见问题及相关原因

    1. svn: Server sent unexpected return value (500 Internal Server Error) in response to OPTIONS reque ...

  10. 用dbforge调试procedure

    工具官网地址:http://www.devart.com/dbforge/mysql/studio/ 对于某些存储过程很多且复杂的SQL的应用,在短时间内要使得所有MySQL存储过程和函数正常运行,那 ...