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