JS:
/// <reference path="../knockout-3.2." /> var ViewModel = function (data) { var self = this; = () = (); = (); = (); = (); var getData = function (wantIndex) { $.getJSON("/BaseInfor/GetList", { pageIndex: wantIndex, pageSize: () }, function (data) { (); (); (); (); }); } = function (item) { getData(item); } = function () { var wantIndex = () - 1; if (wantIndex <= 0) return; getData(wantIndex); } = function () { var wantIndex = () + 1; if (wantIndex - 1 > (() / ())) return; getData(wantIndex); } = function () { getData(1); } = function () { getData(()); } (function () { = (((() / ()))) var pageCount = (); var start = (() - 5) > 0 ? () - 5 : 0; var end = (start + 9) < pageCount ? start + 9 : pageCount; if (end == pageCount) { var start = (pageCount - 9) > 0 ? pageCount - 9 : 0;; } (); for (var i = start; i < end; i++) { ((i + 1)); } }); } $(document).ready(function () { $.getJSON("/BaseInfor/GetList", { pageIndex: 1, pageSize: 5 }, function (data) { (new ViewModel(data)); }); });
HTML:
<table class="table table - striped"> <thead> <tr> <th>Name</th> <th>gender</th> <th>Year of birth</th> <th>age</th> <th>nationality</th> <th>ID number</th> <th>Join the Party time</th> <th>Working hours</th> <th>Hometown</th> <th>place of birth</th> <th>ID photo</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==$() --> <button class="btn btn-success" type="button" data-bind="text:$data,click:$"></button> <!-- /ko --> <!-- ko ifnot: $data==$() --> <button class="btn btn-default" type="button" data-bind="text:$data,click:$"></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()+'Standard data'" /> </div> </div> <script src="/Scripts/jquery-2.1."></script> <script src="/Scripts/knockout-3.2."></script> <script src="/Scripts/"></script> <script src="/Content/Plus/bootstrap-3.2.0-dist/js/"></script> <link href="/Content/Plus/bootstrap-3.2.0-dist/css/" rel="stylesheet" /> <script src="/Scripts/BaseInfor/"></script>
The above is the sharing of the paging control code based on KO+BootStrap+MVC implemented by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!