1. 表格的加载显示

function CreateGrid() {
var store = new dojo.store.Memory({
data: [
{ id: 1, UserName: "User1", Password: "123abc", col4: "编辑" },
{ id: 2, UserName: "User2", Password: "123abc", col4: "编辑" },
{ id: 3, UserName: "User3", Password: "123abc", col4: "编辑" },
{ id: 4, UserName: "User4", Password: "123abc", col4: "编辑" }
]
});

var structure = [
{ id: 'UserName', name: '用户名', field: 'UserName' },
{ id: 'Password', name: '密码', field: 'Password', width: '70px' },
{ id: 'col4', name: '编辑', field: 'col4', width: '75px',
decorator: function (data) {
return "<label class='TableLink'>" + data + "</label>";
}
}];

var grid = new gridx.Grid({
id: 'UserInfoGrid',
style: "width:100%;height:100%;", //height:100%控制表格能否充满所在区域,并随区域大小调整高度
cacheClass: "gridx/core/model/cache/Sync",
store: store,
structure: structure,
selectRowMultiple: true, //与gridx.modules.IndirectSelect一起,控制行首Radio/Checkbox的显示,该属性控制显示Radio或Checkbox
//Declare initialOrder as grid parameter:
sortInitialOrder: { colId: 'UserName', descending: false }, //默认按照name字段升序排列
barTop: [                                                                     //放在[]内的多个工具条,将在一行显示
//[{ content: "<h1>影像数据列表</h1>", colSpan: 6, style: "text-align: center;font-size:12px;"}],
[
{ pluginClass: "gridx/support/QuickFilter", style: 'text-align: right;' }  //查询框,需要与modules配合使用
]
],
barBottom: [
"gridx/support/Summary",
{ pluginClass: "gridx/support/LinkPager", style: 'text-align: center;' },
{ pluginClass: "gridx/support/LinkSizer", style: 'text-align: right;' }
],
modules: [
//Declare this module in the "modules" parameter.
gridx.modules.VirtualVScroller,                        //竖直方向滚动条
gridx.modules.SingleSort,
gridx.modules.Pagination,
gridx.modules.Filter,                  //自动过滤查询框
gridx.modules.Bar,
"gridx/modules/ColumnResizer",  //允许手动调整列宽
gridx.modules.RowHeader,          //显示行首,不显示行首则Radio/Checkbox无法显示
gridx.modules.select.Row,
"gridx/modules/IndirectSelect"    ////与selectRowMultiple一起,控制行首Radio/Checkbox的显示,该插件控制显示
],
selectRowTriggerOnCell: true   //点击行中的任意单元格,选中改行;如果行首有Radio或CheckBox,则同时选中
});

grid.pagination._pageSize = 20;//设置每页显示的行数

grid.startup();
return grid;
}

2. 表格宽度和尺寸的控制

一般情况下,表格需要充满其所在区域,目前我的做法是:

在表格属性中,设置  style: "width:100%;height:100%;", //height:100%控制表格能否充满所在区域,并随区域大小调整高度

此时,表格宽度在页面尺寸变化时,可正常变化,但宽度仍存在问题。为解决宽度不能自动变化的问题,可在页面尺寸变化事件中,手动修改表格宽度

//左右方向充满页面的表格宽度
var newWidth = document.body.clientWidth - 32;  //32为表格与页面之间的间隙,该值不会随页面尺寸等设置变化
dijit.byId("UserInfoGrid").set("style", " width:" + newWidth + "px;");
dijit.byId("UserInfoGrid").resize();

dojo GridX 用法的更多相关文章

  1. dojo query 基本用法

    1. 常用的 dojo.query 用法 dojo.query("#header > h1") //ID 为 header 的元素的直接子节点中的 h3 元素   dojo. ...

  2. DOJO之gridx

    GridX简介 Gridx是IBM公司的职员对Dojo中的Grid进行进一步扩展的组件,但是它是重新开发了Grid而不是继承Grid. 虽然同样都是基于Dojo store, 但与DataGrid/E ...

  3. Dojo的Gridx使用jsonrest需要注意的地方

    在使用gridx时,如果要使用jsonrest,主要的工作主要是在服务端,服务端在返回数据时,必须在返回头里添加Content-Range: 0-9/73 属性和值,其中0表示从第0条记录开始,9表示 ...

  4. Dojo Grid结合Ajax用法

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomerDefine ...

  5. dojo.require()的相关理解

    Dojo 提供了一个非常强大的javascript控件库. 在使用dojo之前,用户基本上不需要具备任何基础知识. 你可以用script远程链接到dojo(dojo.js), 也可以把dojo.js下 ...

  6. Dojo

    dojo的类机制支持类声明.继承.调用父类方法等功能.dojo在底层实现上是通过操作原型链来实现其类机制的,而在实现继承时采用类式继承的方式.值得一提的是,dojo的类机制允许进行多重继承(注意,只有 ...

  7. Events with Dojo(翻译)

    In this tutorial, we will be exploring dojo/on and how Dojo makes it easy to connect to DOM events. ...

  8. Using dojo/query(翻译)

    In this tutorial, we will learn about DOM querying and how the dojo/query module allows you to easil ...

  9. 现代DOJO(翻译)

    http://dojotoolkit.org/documentation/tutorials/1.10/modern_dojo/index.html 你可能已经不用doio一段时间了,或者你一直想保持 ...

随机推荐

  1. Extnet Direct 提交后台事件文件下载设置

    App.direct.MasterData.Export(App.tfSearch.getValue(), {                    isUpload: true            ...

  2. python整理之(字符串、元组、列表、字典)

    一.关于字符串的整理总结 对于字符串的操作常用的有这些: 字符串的操作通过dir()函数可以查看 我们先整理没有下划线的用法,有下划线的暂时不去考虑. 1.capitalize 功能:使字符串的首字母 ...

  3. 控制器(Controller) – ASP.NET MVC 4 系列

           创建一个 ASP.NET MVC 4 Web Application 项目,将程序命名为 MvcMusicStore,如下图: 控制器        MVC 模式中,控制器主要负责响应用 ...

  4. github上传本地项目

    github上传本地项目,分为两个部分: 1.如果建立了ssh key的,直接看第二部分的上传部分就行了 2.如果没有建立ssh key的,就从头开始看吧 ——————————————————我是快乐 ...

  5. BackgroundWorker学习

    后台代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data ...

  6. GDB详解

    1 简介 2 生成调试信息 3 启动GDB 的方法 4 程序运行上下文 4.1 程序运行参数 4.2 工作目录 4.3 程序的输入输出 5 设置断点 5.1 简单断点 5.2 多文件设置断点 5.3 ...

  7. Tips For Your Maya Plugin Development

    (The reason why I write English blog is that I'm trying to improve my written English. The Chinese v ...

  8. 【学】jQuery的源码思路2——$符号是如何封装的

    jQuery中的$符号功能很强大,原因在于对函数参数的个数以及种类的控制,还有对于面向对象思想的运用 function jQuery(args){ //接受参数,并对其判断 this.elements ...

  9. 无法进入adb shell,提示unknown host service的解决办法

    今天monkey的简易环境配置好后,准备开始monkey的压测工作,可是在命令控制窗口中输入无法进入adb shell,提示了错误 "unknown host service"

  10. 样式hack

    1.CSS 重置 html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, ...