grid表格返回参数大都是 以下这种格式(参数名可能不一样)

  1. {
  2.  
  3. data:[{...},{...} ...],
  4. count:39
  5.  
  6. }

 

webix的参数格式为

  1. {
  2. data:[{...},{...},{...}, ...],
  3. pos:8, //从第几行开始接下去,相当于【(page-1)*size】)
  4. total_count:35 //总共有多少条
  5. }

  

webix 分页我目前测出来的情况是返回  total_count  的值是多少 ,初始化的时候回一次查完出来 ,于是我返回的时候只返回 Math.min(page*size +1,count)       +1的原因是为了显示下一页

效果如下

datatable的代码

  1. define(function() {
  2.  
  3. return {
  4. rows: [{
  5. view: "toolbar",
  6. cols: [{
  7. view: "button",
  8. label: "刷新",
  9. type: "iconButton",
  10. icon: "search",
  11. width: 80,
  12. on: {
  13. onItemClick: function() {
  14.  
  15. }
  16. }
  17. }, {
  18. view: "button",
  19. id: "aa",
  20. label: "新增",
  21. type: "iconButton",
  22. icon: "plus",
  23. width: 80,
  24. on: {
  25. onItemClick: function(a, b, c, d) {
  26. console.log(a, b, c, d)
  27. $$("a").add({
  28. $new: true
  29. }, 0);
  30. }
  31. }
  32. }, {
  33. view: "button",
  34. label: "删除",
  35. type: "iconButton",
  36. icon: "trash",
  37. width: 80,
  38. on: {
  39. onItemClick: function() {
  40.  
  41. }
  42. }
  43. }, {
  44. view: "button",
  45. label: "修改",
  46. type: "iconButton",
  47. icon: "wrench",
  48. width: 80,
  49. on: {
  50. onItemClick: function() {
  51.  
  52. /* var datatable = this.getParentView().getParentView()
  53. .getMyDatatable();
  54. var rows = datatable.getMySelectItem();
  55. for(var i = 0; i < rows.length; i++) {
  56. if(rows[i].$new) {
  57. datatable.remove(rows[i].id)
  58. } else {
  59. datatable.hasCss(rows[i].id, "webix_remove_row") ? datatable
  60. .removeCss(rows[i].id, "webix_remove_row") :
  61. datatable.addRowCss(rows[i].id,
  62. "webix_remove_row");
  63. }
  64.  
  65. }*/
  66. }
  67. }
  68. }]
  69. // toolbarElements
  70.  
  71. },
  72. {
  73. view: "datatable",
  74. id: "a",
  75. editable: true,
  76. select: "row",
  77. navigation: true,
  78. datafetch: 20,
  79. rowHeight:33,
  80. loadahead: 15,
  81. tooltip: true,
  82. dragColumn: true,
  83. resizeColumn: true,
  84. columns: [ //
  85. { id: "index", template: "{common.index()}", header: [{ text: "", colspan: 3 }, "<span class='webix_icon fa-list-ol' style='height: 19px;'></span>"], width: 40 },
  86. { id: "ch1", header: ["", { content: "masterCheckbox", contentId: "mc1" }], template: "{common.checkbox()}", width: 40 },
  87. { id: "ra1", header: ["", ""], template: "{common.radio()}", width: 40 },
  88. { id: "sourceId", header: "资源ID", hidden: true },
  89. { id: "sourceCode", header: ["资源代码", { content: "selectFilter" }], editor: "text", sort: "server", width: 140 },
  90. { id: "sourceName", header: ["资源名称", { content: "selectFilter" }], editor: "text", width: 140 },
  91. { id: "pid", header: ["上级资源", { content: "selectFilter" }], editor: "text", width: 140 },
  92. { id: "sourceIcon", header: ["资源图标", { content: "selectFilter" }], editor: "text", width: 160 },
  93. { id: "sourceUrl", header: ["资源URL", { content: "selectFilter" }], editor: "text", width: 200 },
  94. { id: "sourceIndex", header: ["资源排序", { content: "selectFilter" }], editor: "text", width: 140 },
  95. { id: "remark", header: ["备注", { content: "selectFilter" }], editor: "text", width: 140 },
  96. { id: "createTime", header: ["创建时间", { content: "selectFilter" }], width: 160 },
  97. { id: "creater", header: ["创建人", { content: "selectFilter" }], width: 140 },
  98. { id: "updateTime", header: ["更新时间", { content: "selectFilter" }], width: 160 },
  99. { id: "updater", header: ["更新人", { content: "selectFilter" }], width: 140 },
  100. ],
  101. on: {
  102. "data->onStoreUpdated": function() {
  103. this.data.each(function(obj, i) {
  104. //obj.index = i + 1;
  105. })
  106. },
  107. "onBeforeAjax": function(a, b, c, d, e) {
  108. console.log(111)
  109. return true;
  110. }
  111. },
  112. url: "ljx->http://localhost:8080/grid/webix/list",
  113. params: { size: 20 },
  114. pager: "pagerId"
  115. },
  116. {
  117. view: 'pager',
  118. id: "pagerId",
  119. limit: 1,
  120. page: 1,
  121. height: 40,
  122. group: 4, //数据按钮的个数默认最多5个
  123. size: 20,
  124. template: '{common.first()} {common.prev()} {common.pages()} {common.next()} {common.last()} {common.count()} ',
  125.  
  126. }
  127. ]
  128.  
  129. }
  130.  
  131. });

扩展webix的扩展代码

  1. //-----------------------------------------------------------------------------------扩展DataTable--------------------------------------------------------
  2.  
  3. //动态代理
  4. webix.proxy.ljx = {
  5. $proxy: true,
  6. load: function(view, callback, params) {
  7.  
  8. webix.extend(params || {}, this.params || {}, true);
  9.  
  10. //把datatble 下的params 参数 传进来
  11. var view_params = view.config.params || {};
  12.  
  13. if(typeof view_params == "function") {
  14. view_params = view_params(view);
  15. }
  16.  
  17. webix.extend(params || {}, view_params || {}, true);
  18.  
  19. webix.ajax().bind(view).post(this.source, params, callback);
  20. }
  21. };
  22.  
  23. //排序
  24. webix.ui.datatable.prototype.constructor.$protoWait[0].type.index = function() {
  25. return "<span>" + (arguments[4] + 1) + "</span>";
  26. };
  27.  
  28. //排序图标
  29. webix.ui.datatable.prototype.constructor.$protoWait[0].type.indexIcon = function() {
  30. return "<span class='webix_icon fa-list-ol' style='height: 19px;'></span>";
  31. };
  32.  
  33. //-----------------------------------------------------------------------------------扩展pager--------------------------------------------------------
  34.  
  35. //扩展pager 右侧显示
  36. webix.ui.pager.prototype.constructor.$protoWait[0].type.count = function(obj) {
  37. return webix.template("<b style='float:right;line-height: 40px;font-size: 16px;padding-right: 20px;'>第{obj.page} 页 / 共 {obj.limit} 页</b>")({ page: obj.page + 1, limit: obj.limit });
  38. }

  我用的是requrejs管理模块

webix .datatable 表格分页的更多相关文章

  1. 【转】基于jquery的无刷新表格分页

    效果图 css样式 <style> html,body{margin: 0;padding:0} a:focus {outline: none;} /* 通用表格显示 */ table, ...

  2. thinkphp5配合datatable插件分页后端处理程序

    thinkphp5配合datatable插件分页后端处理程序第一版DataTable.php v.1.0 <?php use think\Db; /** * DataTable.php. */ ...

  3. 基于Vue.js的表格分页组件

    有一段时间没更新文章了,主要是因为自己一直在忙着学习新的东西而忘记分享了,实在惭愧. 这不,大半夜发文更一篇文章,分享一个自己编写的一个Vue的小组件,名叫BootPage. 不了解Vue.js的童鞋 ...

  4. Vue.js的表格分页组件

    转自:http://www.cnblogs.com/Leo_wl/p/5522299.html 有一段时间没更新文章了,主要是因为自己一直在忙着学习新的东西而忘记分享了,实在惭愧. 这不,大半夜发文更 ...

  5. Angular.js+Bootstrap实现表格分页

    最近一直学习Angular.js,在学习过程中也练习了很多的Demo,这里先贴一下表格+分页. 先上图看看最终结果: 不得不说Angular.js代码风格很受人欢迎,几十行代码清晰简洁的实现了上面的功 ...

  6. 如何用angularjs制作一个完整的表格之二__表格分页功能

    接上一次,这次主要介绍表格分页功能,由于项目需要这个案例是关于前端分页的方式,现在很少会这么用了,但如有需要可以参考其中的思路 html: 1.通过UL来展示页标,其中每个页标的li是通过异步加载从获 ...

  7. ASP.NET MVC 之表格分页

    简单效果图:(框架:MVC+NHibernate) 要点: (1)首先建立表格分页Model(GridModel.cs) (2)然后建立数据展示页(PageCloth.cshtml) (3)再建分页版 ...

  8. dojo表格分页插件报错

    dojo表格分页插件报错 (1)dojo/parser::parse() error ReferenceError {stack:(...),message:"layout is not d ...

  9. dojo表格分页之各个参数代表的意义(一)

    下面是dojo表格分页参数代表的意义 //每页可以显示10/15/20/25/30条记录 (1)pageSizes: [10, 15, 20, 25,30], //每页显示的记录从多少到多少,共多少条 ...

随机推荐

  1. 游戏UI框架设计(一) : 架构设计理论篇

    游戏UI框架设计(一) ---架构设计理论篇 前几天(2017年2月)看到一篇文章,国内王健林.马云等大咖们看好的未来十大最有"钱途"产业中,排名第一的就是"泛娱乐&qu ...

  2. SharePoint 2016 配置应用程序商店

    最近碰到一个新的需求,就是要给SharePoint配置应用程序商店,挺有意思的,就简单的配置和记录了一下,分享给大家. 其实应用程序商店之前感觉很鸡肋,但是用起来还是不错的.不喜勿喷,呵呵. 首先需要 ...

  3. 第一次AOP,附上使用DEMO,目前只供学习,不可用在生产环境

    GIT代码地址:https://git.oschina.net/ruanjianfeng/Ruan.Framework.Core demo代码如下 public class ConsoleTimeAt ...

  4. Zigbee折腾之旅:(一)CC2530最小系统

    最近在倒腾Zigbee,准备参加物联网全国大赛,学校有给我们发Zigbee开发板,但是对于喜欢折腾的我来说,用开发板还是不过瘾,起码也得知道怎么去画一块板子.于是乎,在百度一番后就有了下面这篇文章. ...

  5. noi 1.8 11图像旋转

    水题不解释 其实我偷懒了 直接输出,,,,,,, 个人QQ:757394026团队QQ:466373640个人博客:www.doubleq.winc++/noi/信息学奥数博客:http://www. ...

  6. 深入浅出Redis-Spring整合Redis

    概述: 在之前的博客中,有提到过Redis 在服务端的一些相关知识,今天主要讲一下Java 整合Redis的相关内容. 下面是Jedis 的相关依赖: <dependency> <g ...

  7. Asp.net缓存技术(HttpRuntime.Cache)

    一.缓存: 5个等级的缓存 1级是网络级缓存,缓存在浏览器,CDN以及代理服务器中   (举个例子:每个帮助页面都进行了缓存,访问一个页面的代码非常简单) 2级是由.net框架 HttpRuntime ...

  8. 2017-02-19C#基础 - 数据类型与类型转换

    数据类型 基本数据类型 1)整形:byte  short  int  long 整数类型 2)浮点型:fioat(.NET类型 Single 值后面要加f float = 10.5f;)  doubl ...

  9. Java面试05|MySQL及InnoDB引擎

    1.InnoDB引擎索引 InnoDB支持的索引有以下几种: (1)哈希索引 (2)全文索引 (1)B+树索引 又可以分为聚集索引与辅助索引 索引的创建可以在CREATE TABLE语句中进行,也可以 ...

  10. 在.NET项目中使用PostSharp,使用MemoryCache实现缓存的处理(转)

    在之前一篇随笔<在.NET项目中使用PostSharp,实现AOP面向切面编程处理>介绍了PostSharp框架的使用,试用PostSharp能给我带来很多便利和优势,减少代码冗余,提高可 ...