1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | const getSelectedIndex = function() {
|
16 | var selectedIndices = this.selectedIndices()
|
17 | if (selectedIndices == null || selectedIndices.length == 0)
|
18 | return -1
|
19 | return selectedIndices[0]
|
20 | };
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | const getSelectedIndices = function() {
|
30 | var selectedIndices = this.selectedIndices()
|
31 | if (selectedIndices == null || selectedIndices.length == 0)
|
32 | return []
|
33 | return selectedIndices
|
34 | };
|
35 |
|
36 |
|
37 | const getSelectedIndexs = function() {
|
38 | return this.getSelectedIndices();
|
39 | }
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | const getSelectedDatas = function(withEmptyRow) {
|
51 | var selectedIndices = this.selectedIndices()
|
52 | var datas = []
|
53 | var sIndices = []
|
54 | for (var i = 0, count = selectedIndices.length; i < count; i++) {
|
55 | sIndices.push(selectedIndices[i])
|
56 | }
|
57 | var rows = this.rows();
|
58 | for (var i = 0, count = rows.length; i < count; i++) {
|
59 | if (sIndices.indexOf(i) != -1)
|
60 | datas.push(rows[i].getData())
|
61 | else if (withEmptyRow == true)
|
62 | datas.push(rows[i].getEmptyData())
|
63 | }
|
64 | return datas
|
65 | };
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | const getSelectedRows = function() {
|
75 | var selectedIndices = this.selectedIndices();
|
76 | var selectRows = [];
|
77 | var rows = this.rows.peek();
|
78 | var sIndices = []
|
79 | for (var i = 0, count = selectedIndices.length; i < count; i++) {
|
80 | sIndices.push(selectedIndices[i])
|
81 | }
|
82 | for (var i = 0, count = rows.length; i < count; i++) {
|
83 | if (sIndices.indexOf(i) != -1)
|
84 | selectRows.push(rows[i])
|
85 | }
|
86 | return selectRows
|
87 | }
|
88 |
|
89 | export const getSelectFunObj = {
|
90 | getSelectedIndex: getSelectedIndex,
|
91 | getSelectedIndices: getSelectedIndices,
|
92 | getSelectedIndexs: getSelectedIndexs,
|
93 | getSelectedDatas: getSelectedDatas,
|
94 | getSelectedRows: getSelectedRows
|
95 | }
|