Skip to content

Commit

Permalink
feat: 增加API getRowsByIndices
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYueKai committed Apr 7, 2017
1 parent e882258 commit 170e590
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/getData.js
Expand Up @@ -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 = {
Expand All @@ -484,5 +499,6 @@ export const getDataFunObj = {
getValue: getValue,
getIndexByRowId: getIndexByRowId,
getAllDatas: getAllDatas,
getRowIdsByIndices: getRowIdsByIndices
getRowIdsByIndices: getRowIdsByIndices,
getRowsByIndices: getRowsByIndices
}
4 changes: 3 additions & 1 deletion src/rowDelete.js
Expand Up @@ -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) {
Expand All @@ -56,7 +57,8 @@ const setRowsDelete = function(indices) {
this.trigger(DataTable.ON_DELETE, {
falseDelete: true,
indices: indices,
rowIds: rowIds
rowIds: rowIds,
rows: rows
})

}
Expand Down

0 comments on commit 170e590

Please sign in to comment.