数据列表 DataList
Constructor
Implements: Widget
Tutorials: 控件对象使用快速入门
可设置的属性
Name | Type | Description |
---|---|---|
name | String | 控件的名字,唯一标志 |
title | String | 控件title |
hidden | Boolean | 隐藏 |
header | Array | 表头 |
data | Array | 数据 |
url | String | 数据URL |
pagination | String | 分页类型(为空或者不设置为不分页) |
pageSize | Number | 每页数据 |
pageNoField | String | 页码field |
pageSizeField | String | 每页数量field |
initNotLoad | Boolean | 初始化不加载数据 |
nextPageText | String | 下一页按钮文本 |
prevPageText | String | 上一页按钮文本 |
loadingText | String | 正在载入提示文本 |
nomoreDataText | String | 没有更多数据提示文本 |
keepSort | Boolean | 是否保持排序状态(更新数据后) |
可读取的属性
Name | Type | Description |
---|---|---|
name | String | 控件的名字,唯一标志 |
title | String | 控件title |
hidden | Boolean | 隐藏 |
url | String | 数据URL |
pagination | String | 分页类型(为空或者不设置为不分页) |
pageSize | Number | 每页数据 |
pageNoField | String | 页码field |
pageSizeField | String | 每页数量field |
initNotLoad | Boolean | 初始化不加载数据 |
nextPageText | String | 下一页按钮文本 |
prevPageText | String | 上一页按钮文本 |
loadingText | String | 正在载入提示文本 |
nomoreDataText | String | 没有更多数据提示文本 |
keepSort | Boolean | 是否保持排序状态(更新数据后) |
方法
reloadData
Description: 重新载入数据
调用举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.doMethod('reloadData');
toPage
Description: 跳转到页
调用参数
Name | Type | Description |
---|---|---|
pageNo | Number | 页码 |
返回值:无
调用举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.doMethod('toPage' , 2);
getRowData
Description: 获取指定行的数据
调用参数
Name | Type | Description |
---|---|---|
rowIndex | Number | 行索引,0开始 |
返回值:Object|undefined 指定行的数据对象,如果没有则返回undefined
调用举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
var rowData = widget.doMethod('getRowData' , 0);
getCellValue
Description: 获取指定单元格的数据
调用参数
Name | Type | Description |
---|---|---|
rowIndex | Number | 行索引,0开始 |
column | String | 列名 |
返回值:Any 指定单元格的值,如果没有则返回undefined
调用举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
var rowData = widget.doMethod('getCellValue' , 0 , 'column1');
sort
Description: 根据指定列数据排序
调用参数
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
column | String | 列名 | ||
desc | Boolean | <optional> | false | 是否逆序 |
返回值:无
调用举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
var rowData = widget.doMethod('sort' , 'column1');
insertRow
Description: 插入一行
调用参数
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
index | Number | <optional> | -1 | 插入位置,-1代表追加(等同appendRow) |
rowData | Object | 行数据 |
返回值:无
调用举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.doMethod('insertRow' , 2 , {column1:'cell1' , column2:'cell2'});
appendRow
Description: 追加一行
调用参数
Name | Type | Description |
---|---|---|
rowData | Object | 行数据 |
返回值:无
调用举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.doMethod('insertRow' , 2 , {column1:'cell1' , column2:'cell2'});
deleteRow
Description: 删除一行
调用参数
Name | Type | Description |
---|---|---|
index | Number | 行号,0开始 |
返回值:无
调用举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.doMethod('deleteRow' , 2);
updateRow
Description: 更新指定行数据
调用参数
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
index | Number | 行号,0开始 | ||
rowData | Object | 行数据 | ||
extend | Boolean | <optional> | false | 是否为继承更新 |
返回值:无
调用举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.doMethod('updateRow' , 2);
hideColumn
Description: 隐藏指定列
调用参数
Name | Type | Description |
---|---|---|
column | String | 列名 |
返回值:无
调用举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.doMethod('hideColumn' , 'column1');
showColumn
Description: 显示指定列
调用参数
Name | Type | Description |
---|---|---|
column | String | 列名 |
返回值:无
调用举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.doMethod('showColumn' , 'column1');
事件
load
Description: 载入数据(多用于处理原始数据到符合表格数据格式的数据)
回调函数参数
Name | Type | Description |
---|---|---|
dataRef | Object | dataRef.data1 为原始数据, dataRef.data2 为处理后数据 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('load' , function(dataRef){
//这里原始数据默认为vjsp后端分页格式数据
//clone data
dataRef.data2 = $.exntend(true , , dataRef.data1);
//给每条数据加一个exval字段
for(var i=0 ; i<dataRef.data2.list.length ; i++){
dataRef.data2.list[i].exval = 'by load event';
}
});
loaded
Description: 载入数据完成
回调函数参数
Name | Type | Description |
---|---|---|
data | Object | 载入的数据,(如果在load事件更改,则此处事更改后的数据) |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('loaded' , function(data){
vjsp.alert('数据载入完成!');
});
clickRow
Description: 单击行
回调函数参数
Name | Type | Description |
---|---|---|
rowIndex | Number | 行索引 |
rowData | Object | 行数据 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('clickRow' , function(rowIndex , rowData){
vjsp.alert('单击 '+rowIndex+' 行');
});
clickCell
Description: 单击单元格
回调函数参数
Name | Type | Description |
---|---|---|
rowIndex | Number | 行索引 |
column | String | 列名 |
value | Any | 单元格的值 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('clickCell' , function(rowIndex , column , value){
vjsp.alert('单元格值:'+value);
});
dblClickRow
Description: 双击行
回调函数参数
Name | Type | Description |
---|---|---|
rowIndex | Number | 行索引 |
rowData | Object | 行数据 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('dblClickRow' , function(rowIndex , rowData){
vjsp.alert('双击 '+rowIndex+' 行');
});
dblClickCell
Description: 双单击单元格
回调函数参数
Name | Type | Description |
---|---|---|
rowIndex | Number | 行索引 |
column | String | 列名 |
value | Any | 单元格的值 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('dblClickCell' , function(rowIndex , column , value){
vjsp.alert('单元格值:'+value);
});
rowRendering
Description: 行渲染
回调函数参数
Name | Type | Description |
---|---|---|
rowIndex | Number | 行索引 |
rowData | Object | 行数据 |
styleObj | Object | 样式对象(回调通过修改此对象添加样式) |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('rowRendering' , function(rowIndex , rowData , styleObj){
//增加红色背景
styleObj.backgroundColor = '#f00';
});
cellRendering
Description: 单元格渲染
回调函数参数
Name | Type | Description |
---|---|---|
rowIndex | Number | 行索引 |
column | String | 列名 |
value | Any | 单元格的值 |
styleObj | Object | 样式对象(回调通过修改此对象添加样式) |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('cellRendering' , function(rowIndex , column , value , styleObj){
//增加红色背景
styleObj.backgroundColor = '#f00';
});
sort
Description: 排序
回调函数参数
Name | Type | Description |
---|---|---|
column | String | 列名 |
val1 | Any | 待比较值1 |
val1 | Any | 待比较值2 |
返回值:Number
通过this.returnValue= 0|1|-1
来返回比较结果
val1 == val2
this.returnValue=0
val1 > val2
this.returnValue=1
val1 < val2
this.returnValue=-1
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('sort' , function(column , val1 , val2){
if(val1 > val2){
this.returnValue = 1;
}else if(val1 < val2){
this.returnValue = -1;
}else{
this.returnValue = 0;
}
});
insertRow
Description: 插入数据,插入动作已经完成(调用appendRow触发此事件)
回调函数参数
Name | Type | Description |
---|---|---|
rowIndex | Number | 插入索引 |
rowData | Object | 插入数据 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('insertRow' , function(rowIndex , rowData){
vjsp.alert('插入到:'+rowIndex+' 行');
});
deleteRow
Description: 删除数据,删除动作已经完成
回调函数参数
Name | Type | Description |
---|---|---|
rowIndex | Number | 删除索引 |
rowData | Object | 删除数据 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('deleteRow' , function(rowIndex , rowData){
vjsp.alert('删除第:'+rowIndex+' 行');
});
updateRow
Description: 更新数据,更新动作已经完成
回调函数参数
Name | Type | Description |
---|---|---|
rowIndex | Number | 更新索引 |
rowData | Object | 新数据 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('updateRow' , function(rowIndex , rowData){
vjsp.alert('更新第:'+rowIndex+' 行');
});
hidden
Description: 隐藏事件(隐藏显示触发 回调参数为隐藏状态)
回调函数参数
Name | Type | Description |
---|---|---|
hiddenState | Boolean | 隐藏状态true 为隐藏、false 为取消隐藏 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('dataList');
widget.on('hidden' , function(hiddenState){
if(hiddenState){
vjsp.alert('控件被隐藏');
}else{
vjsp.alert('控件取消隐藏');
}
});
列属性
属性:
Name | Type | Description |
---|---|---|
name | String | 列名 |
title | String | 列显示名 |
width | Number | 宽度 |
hidden | Boolean | 列隐藏 |
align | String | 数据对齐(left|center|right) |
sortable | Boolean | 是否开启排序 |
nowrap | Boolean | 是否开强制不换行 |
hidden | 隐藏事件(隐藏显示触发 回调参数为隐藏状态) | |
nvcolumn | Boolean | 是否非数据列(true不提交此列数据) |