jquery之插件mmgrid的使用方法

标签:
itjquery |
分类: jquery |
名称 | 参数 | 描述 |
---|---|---|
load | {} | [] | 如果配置过AJAX选项,则这里是AJAX参数,如果传入对象数组,则为加载本地数据。 |
selectedRows | 无参数 | 返回选择行数据的数组。 |
selectedRowsIndex | 无参数 | 返回选择行索引的数组。 |
select | int | function(item, index){ return true; } | 'all' | 选中参数条件的行。int: 选中索引行; function: 过滤函数, item参数为行数据, index参数为行索引; 'all': 选中所有行。 |
deselect | int | function(item, index){ return true; } | 'all' | 取消选中参数条件的行。int: 取消选择索引行; function: 过滤函数, item参数为行数据, index参数为行索引; 'all': 取消选中所有行。 |
rows | 无参数 | 返回所有行的数据数组。 |
row | int | 返回指定索引行的数据。 |
rowsLength | 无参数 | 返回行数。 |
addRow | item,index | 添加数据到索引行,index为可选。如item为对象数组则一次添加多行。 |
updateRow | item,index | 更新数据到索引行,index为必选。一次只能更新一行。 |
removeRow | index | 移除索引行。如index为索引数组则一次移除多行。如果index为undefined则移除所有行。 |
名称 | 可选值 | 描述 |
---|---|---|
width | 'auto', 500, '500px' | 表格宽度。参数为'auto'和以'%'结尾,表格可在调整窗口尺寸时根据父元素调整尺寸。 |
height | '280px', 500, '500px' | 表格高度。如果以'%'结尾,表格可在调整窗口尺寸时根据父元素调整尺寸。如果设置为'auto',表格显示全部行,不显示垂直滚动条 |
url | false, string | AJAX请求数据的地址。 |
params | {}, object, function(){ return {}; } | AJAX请求的参数。可以是普通对象或函数。 函数返回一个参数对象,每次调用AJAX时调用。 |
method | 'post', 'get' | AJAX提交方式。 |
ache | false, true | AJAX缓存。 |
items | [], Array | 数据使用本地对象数组。 |
root | '', string | 指定json对象的数组字段为数据。 |
nowrap | false, true | 表格显示的数据超出列宽时是否换行。 |
multiSelect | false, true | 数据使用本地对象数组。 |
fullWidthRows | false, true | true:表格第一次加载数据时列伸展,自动充满表格。 |
checkCol | false, true | 表格显示checkbox |
indexCol | false, true | 表格显示索引列 |
indexColWidth | 30 | 表格索引列宽度 |
loadingText | '正在载入...', string | 数据载入时的提示文字。 |
noDataText | '没有数据', string | 没有数据时的提示文字。 |
cols | [], Array | 数据模型。 |
sortName | '', string | 排序的字段名。字段名的值为列模型设置的sortName或name中的值。 |
sortStatus | 'asc', string | 排序方向。 |
remoteSort | false, true | 是否使用服务器端排序。当值为true时,sortName和sortStatus会作为参数放入AJAX请求中。 |
autoLoad | true, false | 是否表格准备好时加载数据。 |
showBackboard | true, false | 是否显示选项背板。 |
plugins | [] | 表格插件,插件必须实现 init($mmGrid)和params()方法,参考mmPaginator |
二.列选项
名称 | 可选值 | 描述 |
---|---|---|
title | string | 标题文字。 |
titleHtml | string | 标题文字的HTML代码。 |
width | int | 标题宽度像素值,默认为100。 |
name | string | 字段名。 |
align | 'left', 'center', 'right' | 文字位置。 |
hidden | false, true | 是否隐藏列。 |
lockDisplay | false, true | 是否锁定列的显示状态。 |
lockWidth | false, true | 是否锁定列宽。被锁定的列不参与fitCols选项的计算。 |
sortable | false, true | 是否可排序。 |
sortName | string | 当sortable为true,远程排序发出的字段名,如果这个字段名为空,则发出的字段名为name的值 |
renderer | function(val,item,rowIndex){ return val;} | 显示规则。参数: val 值, item 对象, rowIndex 行索引; 返回值: 可以是纯文本或html。 |
type | 'number' | 字段类型。只用于数字的本地排序。 |
cols | [], Array | 数据模型。用于表头分组,目前只支持两层。 |
三.表操作
名称 | 参数 | 描述 |
---|---|---|
load | {} | [] | 如果配置过AJAX选项,则这里是AJAX参数,如果传入对象数组,则为加载本地数据。 |
selectedRows | 无参数 | 返回选择行数据的数组。 |
selectedRowsIndex | 无参数 | 返回选择行索引的数组。 |
select | int | function(item, index){ return true; } | 'all' | 选中参数条件的行。int: 选中索引行; function: 过滤函数, item参数为行数据, index参数为行索引; 'all': 选中所有行。 |
deselect | int | function(item, index){ return true; } | 'all' | 取消选中参数条件的行。int: 取消选择索引行; function: 过滤函数, item参数为行数据, index参数为行索引; 'all': 取消选中所有行。 |
rows | 无参数 | 返回所有行的数据数组。 |
row | int | 返回指定索引行的数据。 |
rowsLength | 无参数 | 返回行数。 |
addRow | item,index | 添加数据到索引行,index为可选。如item为对象数组则一次添加多行。 |
updateRow | item,index | 更新数据到索引行,index为必选。一次只能更新一行。 |
removeRow | index | 移除索引行。如index为索引数组则一次移除多行。如果index为undefined则移除所有行。 |
四.事件
名称 | 参数 | 描述 |
---|---|---|
loadSuccess | function(e, data){} | 数据加载成功后执行。 |
loadError | function(e, data){} | 数据加载失败后执行。 |
cellSelected | function(e, item, rowIndex, colIndex){} | 表格中的单元格被选择后执行。item:被选择单元格所在行对应的数据对象;rowIndex:行索引;colIndex:列索引。 |
rowInserted | function(e, item, index){} | 表格中的数据被插入后执行。item:插入的数据对象;index:行索引。 |
rowUpdated | function(e, oldItem, newItem, index){} | 表格中的数据被更新后执行。oldItem:更新前的数据对象;newItem:更新后的数据对象;index:行索引。 |
rowRemoved | function(e, item, index){} | 表格中的数据被删除后执行。oldItem:被删除行的数据对象;index:被删除前的行索引。 |
1,root
:'items',items对象是必须存在的,否则表格在没有数据时不会提示“没有数据”,并且默认的水平和垂直滚动条都会没有。对象存在,但对象里的内容为空时显示没有数据,对象不存在时就会出现上述情况。,
2,滚动条不出现的解决办法:
在表格初始化时加以下代码:
3,在表格中使用处理函数:
其中,var是该列数据,item是该行包含所有列数据的对象,rowindex所在行的行值。
经过一段时间的使用后,个人对其进行了一些扩展,加上这篇文章发布后,很多人对其的使用还是有疑问。故重新写了一篇更加详细的教程:详见:另一篇介绍地址:http://blog.csdn.net/u014435531/article/details/78021775。
前一篇:jquery中的$.fn对的用法