diff --git a/src/getData.js b/src/getData.js index 0a35f98..142286a 100644 --- a/src/getData.js +++ b/src/getData.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 } diff --git a/src/rowDelete.js b/src/rowDelete.js index 49c1706..1fb4e9d 100644 --- a/src/rowDelete.js +++ b/src/rowDelete.js @@ -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 }) }