-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
388 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,74 +1,74 @@ | |||
/** | /** | ||
* Module : kero dataTable removeRow | * Module : kero dataTable removeRow | ||
* Author : liuyk(liuyk@yonyou.com) | * Author : liuyk(liuyk@yonyou.com) | ||
* Date : 2016-08-01 14:34:01 | * Date : 2016-08-01 14:34:01 | ||
*/ | */ | ||
import {_formatToIndicesArray} from './util'; | import {_formatToIndicesArray} from './util'; | ||
|
|
||
const removeRowByRowId = function (rowId) { | const removeRowByRowId = function (rowId) { | ||
var index = this.getIndexByRowId(rowId) | var index = this.getIndexByRowId(rowId) | ||
if (index != -1) | if (index != -1) | ||
this.removeRow(index) | this.removeRow(index) | ||
} | } | ||
|
|
||
const removeRow = function (index) { | const removeRow = function (index) { | ||
if (index instanceof Row) { | if (index instanceof Row) { | ||
index = this.getIndexByRowId(index.rowId) | index = this.getIndexByRowId(index.rowId) | ||
} | } | ||
this.removeRows([index]); | this.removeRows([index]); | ||
} | } | ||
|
|
||
const removeAllRows = function () { | const removeAllRows = function () { | ||
this.rows([]) | this.rows([]) | ||
this.selectedIndices([]) | this.selectedIndices([]) | ||
this.focusIndex(-1) | this.focusIndex(-1) | ||
this.trigger(DataTable.ON_DELETE_ALL) | this.trigger(DataTable.ON_DELETE_ALL) | ||
this.updateCurrIndex(); | this.updateCurrIndex(); | ||
} | } | ||
|
|
||
const removeRows = function (indices) { | const removeRows = function (indices) { | ||
indices = _formatToIndicesArray(indices) | indices = _formatToIndicesArray(this, indices) | ||
indices = indices.sort() | indices = indices.sort() | ||
var rowIds = [], rows = this.rows(), deleteRows = []; | var rowIds = [], rows = this.rows(), deleteRows = []; | ||
for (var i = indices.length - 1; i >= 0; i--) { | for (var i = indices.length - 1; i >= 0; i--) { | ||
var index = indices[i] | var index = indices[i] | ||
var delRow = rows[index]; | var delRow = rows[index]; | ||
if (delRow == null) { | if (delRow == null) { | ||
continue; | continue; | ||
} | } | ||
rowIds.push(delRow.rowId) | rowIds.push(delRow.rowId) | ||
var deleteRow = rows.splice(index, 1); | var deleteRow = rows.splice(index, 1); | ||
deleteRows.push(deleteRow[0]); | deleteRows.push(deleteRow[0]); | ||
this.updateSelectedIndices(index, '-') | this.updateSelectedIndices(index, '-') | ||
this.updateFocusIndex(index, '-') | this.updateFocusIndex(index, '-') | ||
} | } | ||
this.rows(rows) | this.rows(rows) | ||
this.deleteRows = deleteRows; | this.deleteRows = deleteRows; | ||
this.trigger(DataTable.ON_DELETE, { | this.trigger(DataTable.ON_DELETE, { | ||
indices: indices, | indices: indices, | ||
rowIds: rowIds, | rowIds: rowIds, | ||
deleteRows: deleteRows | deleteRows: deleteRows | ||
}) | }) | ||
this.updateCurrIndex(); | this.updateCurrIndex(); | ||
} | } | ||
|
|
||
|
|
||
/** | /** | ||
* 清空datatable的所有数据以及分页数据以及index | * 清空datatable的所有数据以及分页数据以及index | ||
*/ | */ | ||
const clear = function () { | const clear = function () { | ||
this.removeAllRows(); | this.removeAllRows(); | ||
this.cachedPages = []; | this.cachedPages = []; | ||
this.totalPages(1); | this.totalPages(1); | ||
this.pageIndex(0); | this.pageIndex(0); | ||
this.focusIndex(-1); | this.focusIndex(-1); | ||
this.selectedIndices([]); | this.selectedIndices([]); | ||
} | } | ||
|
|
||
export { | export { | ||
removeRowByRowId, | removeRowByRowId, | ||
removeRow, | removeRow, | ||
removeAllRows, | removeAllRows, | ||
removeRows, | removeRows, | ||
clear | clear | ||
} | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.