Permalink
Browse files

feat: 增加API getRowsByIndices

  • Loading branch information...
LiuYueKai committed Apr 7, 2017
1 parent e882258 commit 170e590f7b2d027b50ef1c66501ff4aa83df9a79
Showing with 20 additions and 2 deletions.
  1. +17 −1 src/getData.js
  2. +3 −1 src/rowDelete.js
@@ -465,6 +465,21 @@ const getRowIdsByIndices = function(indices) {
}
return rowIds
}
/**
* 根据索引获取row
* @memberof DataTable
* @param {array} indices 需要获取rowid的索引值
* @return {array} 获取到的row
* @example
* datatable.getRowIdsByIndices([1,2,5])
*/
const getRowsByIndices = function(indices) {
var rows = []
for (var i = 0; i < indices.length; i++) {
rows.push(this.getRow(indices[i]))
}
return rows
}


export const getDataFunObj = {
@@ -484,5 +499,6 @@ export const getDataFunObj = {
getValue: getValue,
getIndexByRowId: getIndexByRowId,
getAllDatas: getAllDatas,
getRowIdsByIndices: getRowIdsByIndices
getRowIdsByIndices: getRowIdsByIndices,
getRowsByIndices: getRowsByIndices
}
@@ -40,6 +40,7 @@ const setRowsDelete = function(indices) {
return b - a;
});
var rowIds = this.getRowIdsByIndices(indices)
var rows = this.getRowsByIndices(indices);
for (var i = 0; i < indices.length; i++) {
var row = this.getRow(indices[i])
if (row.status == Row.STATUS.NEW) {
@@ -56,7 +57,8 @@ const setRowsDelete = function(indices) {
this.trigger(DataTable.ON_DELETE, {
falseDelete: true,
indices: indices,
rowIds: rowIds
rowIds: rowIds,
rows: rows
})

}

0 comments on commit 170e590

Please sign in to comment.