Dojo异步数据和分页简单剖析
来源:互联网 发布:mac 最大化 快捷键 编辑:程序博客网 时间:2024/05/01 09:22
Dojo异步数据和分页简单剖析
Dojo 从 v1.0 开始引入了一个功能强大,快速,健壮的控件--Grid。Grid 在dojo的体系结构中属于Dojox 这个包中。这个Grid 比较灵活,可以排序,过滤,编辑,多表头,支持多种Cell 控件。要完成一个Grid,需要下面几个步骤,每个步骤都是必不可少的。
1、导入样式表
没有样式表,就无法显示漂亮的列表出来,你看到的将是丑陋的静态文本。
css 代码
1. < style type="text/css">
2. @import http://localhost/dojo/dojo/resources/dojo.css
3. @import http://localhost/dojo/dijit/themes/soria/soria.css
4. @import "http://localhost/dojo/dojox/grid/resources/soriaGrid.css";
5. @import "http://localhost/dojo/dojox/grid/enhanced/resources/EnhancedGrid_rtl.css";
6. @import "http://localhost/dojo/dojox/grid/enhanced/resources/EnhancedGrid.css";
7. @import "http://localhost/dojo/dojox/grid/enhanced/resources/Pagination.css";
8. < / style>
2、Js引入
9. dojo.require("dojox.grid.EnhancedGrid");
10. dojo.require("dojox.grid.enhanced.plugins.Pagination");
11. dojo.require("dojox.data.QueryReadStore");
12. dojo.require("dojox.grid.enhanced.plugins.IndirectSelection");
13. dojo.require("dojo.parser");
3、数据源(store)
Grid的显示,数据源是必不可少的,本次为了采用异步获取数据源,使用dojox.data.QueryReadStore方法,具体使用代码如下:
1. var store = new dojox.data.QueryReadStore({
2. url:'http://localhost:8080/grid',//请求服务的地址
3. requestMethod:"post" //获取数据源的方式
4. });
视图(View)
View 用来定义每个数据列,一个view是多个数据列的组合。通过定义view,使Grid按照要求来显示数据。下面是一个简单的view定义。
js 代码
5. var view = [[ {
6. name: "角色名称",
7. field:"name",
8. //styles:"text-align:right;",
9. width: 30
10. },
11. {
12. name: "所属部门",
13. field:"type",
14. width:'auto'
15. //formatter:rs.chunk.adminUser.grid.formatUser
16. }
17. ]];
4、分页插件(plugins)
dojo grid自带了分页控件dojox.grid.enhanced.plugins.Pagination,使用Pagination我们可以进行数据分页,他应用非常简单,代码如下:
18. var plugins = {
19. indirectSelection:{//checkbox选框
20. headerSelector:true,
21. name: "Selection",
22. width:"30px",
23. styles:"text-align: center;"
24. },
25. pagination: {
26. pageSizes: [4, 8, 12, 16, 20, Infinity],//Array, custom the items per page button
27. description: true, // boolean, custom whether or not the description will bedisplayed
28. sizeSwitch: true, // boolean, custom whether or not the page size switch will bedisplayed
29. pageStepper: true, // boolean, custom whether or not the page step will be displayed
30. gotoButton: true, // boolean, custom whether or not the goto page button will bedisplayed
31. maxPageStep: 10, // Integer, custom how many page step will be displayed
32. position: "bottom", // String, custom the position of thepagination bar. There're two options: top, bottom
33. defaultPage: 1, // Integer, which page will be displayed by default
34. defaultPageSize: 4 // Integer, what pagesize will be used by default
35. }
36. };
5、定义EnhancedGrid
37. var grid = new dojox.grid.EnhancedGrid(dojo.mixin({
38. id:"grid1",
39. store:store,
40. structure:view,
41. plugins: plugins
42. },gridArgs));
43. dojo.byId("gridContainer").appendChild(grid.domNode);
44. grid.startup();
6、写body
45. <divid="gridContainer" style="height:100%;"></div>
7、后台参数获取
46. Stringstart = request.getParameter("start");//每页的开始行数
47. Stringcount = request.getParameter("count");//每页显示的条数
- Dojo异步数据和分页简单剖析
- 异步请求数据和Js分页控件结合使用心得
- dojo异步编程 dojo/Deferred
- 如何使用 Dojo EnhancedGrid 控件进行数据异步保存
- 简单的数据分页
- winform简单的UI和数据异步加载
- dojo之异步编程
- Jquery Datatables 异步分页加载数据
- 给select框加上onchange事件,数据以json返回,异步刷新和js分页
- 剖析异步
- 数据绑定控件 简单分页
- Thinkphp 实现简单数据分页
- MVCPager 分页: 异步和同步Demo
- dojo.publish 和 dojo.subscribe
- JSP 分页(二) ----异步一览列表和分页
- dojo表格分页报错
- 深入了解 Dojo 的数据访问和绑定工具包
- 【Dojo学习之六】Ajax 数据接受和发送
- VE界面切换方法及各界面效果简要介绍
- 【Unity 3D 游戏引擎】建立3D场景
- android ListView的上部下拉刷新下部点击加载更多具体实现及拓展
- ADF运行jsp的时候出现 JSP scriptlets will not work properly if using OJSP
- 【计算机网络】计算机网络面试题系列一
- Dojo异步数据和分页简单剖析
- 【91xcz】必看:WinRAR容易被人忽略的技巧两则
- Silverlight WCF RIA服务(二十二)Silverlight 客户端 3
- android 仿iPhone提示 标签 背景 圆形
- usb
- 【计算机网络】计算机网络面试题系列二
- 在Android模拟器上安装应用程序
- gerrit 安装笔记
- Static / Const 的概念