名称 |
可选值 |
描述 |
width |
'auto', 500, '500px' |
表格宽度。参数为'auto'和以'%'结尾,表格可在调整窗口尺寸时根据父元素调整尺寸。 |
height |
'280px', 500, '500px' |
表格高度。如果以'%'结尾,表格可在调整窗口尺寸时根据父元素调整尺寸。如果设置为'auto',表格显示全部行,不显示垂直滚动条 |
url |
false, string |
AJAX请求数据的地址。 |
params |
{}, object, function(){ return {}; } |
AJAX请求的参数。可以是普通对象或函数。
函数返回一个参数对象,每次调用AJAX时调用。如果返回为空则不会调用AJAX。
|
method |
'post', 'get' |
AJAX提交方式。 |
cache |
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 |
没有数据时的提示文字。 |
loadErrorText |
'数据加载出现异常', 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 |
名称 |
参数 |
描述 |
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:被删除前的行索引。
|