Permalink
Browse files

feat: datatable对象的getSimpleData支持跨页选择后获取选中数据

  • Loading branch information...
LiuYueKai committed Jun 14, 2017
1 parent 0a7ae79 commit 3fae27ebdab4bb8f3f775ab2eb4cae27c8bc08e1
Showing with 43 additions and 7 deletions.
  1. +24 −7 src/getSimpleData.js
  2. +19 −0 src/page-getData.js
View
@@ -27,18 +27,35 @@ const getSimpleData = function(options) {
type = options['type'] || 'all',
fields = options['fields'] || null;
if (type === 'all') {
rows = this.rows.peek();
} else if (type === 'current') {
if (type === 'current') {
var currRow = this.getCurrentRow();
rows = currRow == null ? [] : [currRow];
} else if (type === 'focus') {
var focusRow = this.getFocusRow();
rows = focusRow == null ? [] : [focusRow];
} else if (type === 'select') {
rows = this.getSelectedRows();
} else if (type === 'change') {
rows = this.getChangedRows();
} else {
if (this.pageCache) {
var pages = this.getPages();
rows = []
for (var i = 0; i < pages.length; i++) {
var page = pages[i];
if (type === 'all') {
rows = rows.concat(page.rows.peek());
}else if(type === 'select') {
rows = rows.concat(page.getSelectRows());
} else if (type === 'change') {
rows = rows.concat(page.getSelectRows());
}
}
} else {
if (type === 'all') {
rows = this.rows.peek();
} else if (type === 'select') {
rows = this.getSelectedRows();
} else if (type === 'change') {
rows = this.getChangedRows();
}
}
}
for (var i = 0; i < rows.length; i++) {
View
@@ -72,6 +72,24 @@ const getSelectRows = function() {
return rows
}
/**
* 获取发生改变的Row对象
* @memberof DataTable
* @return {array} 发生改变的Row对象
* @example
* datatable.getChangedRows()
*/
const getChangedRows = function() {
var changedRows = [],
rows = this.rows.peek();
for (var i = 0, count = rows.length; i < count; i++) {
if (rows[i] && rows[i].status != Row.STATUS.NORMAL) {
changedRows.push(rows[i])
}
}
return changedRows
}
/**
* 根据rowid获取Row对象
* @memberof Page
@@ -109,6 +127,7 @@ export const pageGetDataFunObj = {
getData: getData,
getSelectDatas: getSelectDatas,
getSelectRows: getSelectRows,
getChangedRows: getChangedRows,
getRowByRowId: getRowByRowId,
getRowValue: getRowValue
}

0 comments on commit 3fae27e

Please sign in to comment.