1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import {_formatToIndicesArray} from './util';
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | const setRowDelete = function (index) {
|
14 | if (index instanceof Row) {
|
15 | index = this.getIndexByRowId(index.rowId)
|
16 | }
|
17 | this.setRowsDelete([index])
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | const setAllRowsDelete = function () {
|
24 | var indices = new Array(this.rows().length)
|
25 | for (var i = 0; i < indices.length; i++) {
|
26 | indices[i] = i
|
27 | }
|
28 | this.setRowsDelete(indices)
|
29 | }
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | const setRowsDelete = function (indices) {
|
36 | indices = _formatToIndicesArray(this, indices)
|
37 | var rowIds = this.getRowIdsByIndices(indices)
|
38 | this.trigger(DataTable.ON_DELETE, {
|
39 | falseDelete: true,
|
40 | indices: indices,
|
41 | rowIds: rowIds
|
42 | })
|
43 | for (var i = 0; i < indices.length; i++) {
|
44 | var row = this.getRow(indices[i])
|
45 | if (row.status == Row.STATUS.NEW) {
|
46 | this.rows().splice(indices[i], 1);
|
47 | this.updateSelectedIndices(indices[i], '-')
|
48 | this.updateFocusIndex(index, '-')
|
49 | }
|
50 | else {
|
51 | row.status = Row.STATUS.FALSE_DELETE
|
52 | var temprows = this.rows().splice(indices[i], 1)
|
53 | this.rows().push(temprows[0]);
|
54 | }
|
55 | }
|
56 | }
|
57 |
|
58 | export {
|
59 | setRowDelete,
|
60 | setAllRowsDelete,
|
61 | setRowsDelete
|
62 | } |
\ | No newline at end of file |