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. jQuery轮播

    一,简单实现轮播  //轮播容器 .carousel   //轮播容器--可设宽度      (carousel="轮播") //轮播指标 .carousel-indicators ...

  2. java多线程之CAS

    前言 在Java并发包中有这样一个包,java.util.concurrent.atomic,该包是对Java部分数据类型的原子封装,在原有数据类型的基础上,提供了原子性的操作方法,保证了线程安全.下 ...

  3. .NET 4.5 WPF Ribbon

    文/嶽永鹏 Visual Studio 2012  DO.NET 4.5 Ribbon 界面编程. 代码 =============================================== ...

  4. Mysql 5.7.10以上版本安装大坑

    mysql解压缩版的配置已经方便无比了,但是也正是由于官方的不断优化,导致传统的套路一次次被修改.也让像我这样的萌新撞了个大墙. [注:本篇博客适用mysql5.7.10~5.7.15,如果版本已太过 ...

  5. 编写windows版ANE

    1.编写WinANE.dll: #include <windows.h> #include <stdlib.h> #include <FlashRuntimeExtens ...

  6. 谈谈Javascript的this关键字(this is not this)

    前言: 看文章标题你就知道,这篇文章我只讲一个简单的Javascript的this关键字,说它简单——它又不简单,因为曾几何时我也对this关键字有些困惑,它也确实会让不少程序员感到不解——它像是一个 ...

  7. AJAX浏览器判断

    第一步要先获取对象: var xmlHttp; 第二是判断浏览器 function getXmlHttp(){ if(window.ActiveXObject){ xmlHttp = new Acti ...

  8. 优化ubuntu桌面

    ---恢复内容开始--- 此博主写的很全 http://blog.csdn.net/terence1212/article/details/52270210 使用安装Unity Tweak Tool ...

  9. Jupyter notebook 安装,初步使用

    在学习算法,图像处理过程中,理论结合实际的时候总要写一些程序,我用的是PYTHON.这时候,选择一款称手的工具比较重要.之前我用自带的IDLE,也还可以,但是操作不够便捷,文件组织也不是很好.后来想用 ...

  10. 6、httpd服务的安装、配置

    .本地yum源安装httpd服务 (必须是已搭建好本地yum源) yum install httpd -y (安装httpd) 2.systemctl restart httpd.service   ...