1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import { utilFunObj } from './util';
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | var setRowDelete = function setRowDelete(index) {
|
14 | if (index instanceof Row) {
|
15 | index = this.getIndexByRowId(index.rowId);
|
16 | }
|
17 | this.setRowsDelete([index]);
|
18 | };
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | var setAllRowsDelete = function setAllRowsDelete() {
|
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 | var setRowsDelete = function setRowsDelete(indices) {
|
36 | indices = utilFunObj._formatToIndicesArray(this, indices);
|
37 | indices = indices.sort(function (a, b) {
|
38 | return b - a;
|
39 | });
|
40 | var rowIds = this.getRowIdsByIndices(indices);
|
41 | var rows = this.getRowsByIndices(indices);
|
42 | var ros = this.rows();
|
43 | for (var i = 0; i < indices.length; i++) {
|
44 | var row = this.getRow(indices[i]);
|
45 | if (row.status == Row.STATUS.NEW || this.forceDel) {
|
46 | ros.splice(indices[i], 1);
|
47 | } else {
|
48 | row.setStatus(Row.STATUS.FALSE_DELETE);
|
49 | var temprows = ros.splice(indices[i], 1);
|
50 | ros.push(temprows[0]);
|
51 | }
|
52 | this.updateSelectedIndices(indices[i], '-');
|
53 | this.updateFocusIndex(indices[i], '-');
|
54 | }
|
55 | this.rows(ros);
|
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 | export var rowDeleteFunObj = {
|
66 | setRowDelete: setRowDelete,
|
67 | setAllRowsDelete: setAllRowsDelete,
|
68 | setRowsDelete: setRowsDelete
|
69 | }; |
\ | No newline at end of file |