@refinitiv-ui/efx-grid 6.0.150 → 6.0.151
Sign up to get free protection for your applications and to get access to all the features.
@@ -5,21 +5,76 @@ import FormatterBuilder from "./FormatterBuilder.js";
|
|
5
5
|
* @property {number=} initialIndex
|
6
6
|
*/
|
7
7
|
|
8
|
+
/** @private
|
9
|
+
* @function
|
10
|
+
* @param {number|string} rowRef
|
11
|
+
* @param {boolean=} checked
|
12
|
+
* @returns {boolean} Returns true if there is a change
|
13
|
+
*/
|
14
|
+
let _selectRadio = function (rowRef, checked) {
|
15
|
+
if(!this.grid) {
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
let dv = this.grid.getDataSource();
|
19
|
+
if(!dv) {
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
|
23
|
+
let rowIndex = -1;
|
24
|
+
let rid = "";
|
25
|
+
if(typeof rowRef == "string") {
|
26
|
+
rid = rowRef;
|
27
|
+
rowIndex = dv.getRowIndex(rid);
|
28
|
+
} else {
|
29
|
+
rowIndex = rowRef;
|
30
|
+
rid = dv.getRowId(rowIndex);
|
31
|
+
}
|
32
|
+
if(!(rowIndex >= 0) || !rid) {
|
33
|
+
return false;
|
34
|
+
}
|
35
|
+
|
36
|
+
let dirty = false;
|
37
|
+
if (checked !== false) {
|
38
|
+
if (this.previousId && this.previousId !== rid) {
|
39
|
+
this.rowIndex = dv.getRowIndex(this.previousId);
|
40
|
+
this.setData(this.field, false);
|
41
|
+
}
|
42
|
+
this.rowIndex = rowIndex;
|
43
|
+
this.previousId = rid;
|
44
|
+
this.setData(this.field, true);
|
45
|
+
this.value = checked;
|
46
|
+
dirty = true;
|
47
|
+
} else if(this.previousId == rid) {
|
48
|
+
this.rowIndex = rowIndex;
|
49
|
+
this.previousId = "";
|
50
|
+
this.setData(this.field, false);
|
51
|
+
this.value = false;
|
52
|
+
dirty = true;
|
53
|
+
}
|
54
|
+
return dirty;
|
55
|
+
};
|
56
|
+
|
8
57
|
/** @private
|
9
58
|
* @function
|
10
59
|
* @param {Element} element
|
11
60
|
* @param {Object} ctx
|
12
61
|
*/
|
13
62
|
let onElementCreated = function (element, ctx) {
|
14
|
-
let
|
15
|
-
let rid =
|
16
|
-
|
17
|
-
|
63
|
+
let checked = false;
|
64
|
+
let rid = "";
|
65
|
+
if(ctx.initialIndex >= 0) {
|
66
|
+
let dv = ctx.grid.getDataSource();
|
67
|
+
rid = dv.getRowId(ctx.rowIndex);
|
68
|
+
if(!ctx.initialRid) {
|
69
|
+
ctx.initialRid = dv.getRowId(ctx.initialIndex);
|
70
|
+
}
|
71
|
+
checked = (rid === ctx.initialRid);
|
72
|
+
}
|
18
73
|
if (checked) {
|
19
74
|
ctx.previousId = rid;
|
20
75
|
ctx.setData(ctx.field, checked);
|
76
|
+
ctx.value = checked;
|
21
77
|
}
|
22
|
-
ctx.value = checked;
|
23
78
|
};
|
24
79
|
|
25
80
|
/** @private
|
@@ -28,9 +83,10 @@ let onElementCreated = function (element, ctx) {
|
|
28
83
|
* @param {Object} ctx
|
29
84
|
*/
|
30
85
|
let onElementUpdated = function (element, ctx) {
|
31
|
-
let
|
32
|
-
|
33
|
-
|
86
|
+
let checked = ctx.value ? true : false;
|
87
|
+
if(checked) {
|
88
|
+
checked = (ctx.grid.getDataSource().getRowId(ctx.rowIndex) === ctx.previousId);
|
89
|
+
}
|
34
90
|
element.checked = checked;
|
35
91
|
};
|
36
92
|
|
@@ -40,22 +96,7 @@ let onElementUpdated = function (element, ctx) {
|
|
40
96
|
* @param {*} ctx
|
41
97
|
*/
|
42
98
|
let _changeHandler = function (e, ctx) {
|
43
|
-
ctx.
|
44
|
-
ctx.setData(ctx.field, ctx.value);
|
45
|
-
|
46
|
-
let dv = ctx.grid.getDataSource();
|
47
|
-
let rid = dv.getRowId(ctx.rowIndex);
|
48
|
-
if (ctx.previousId && ctx.previousId !== rid) {
|
49
|
-
let row = dv.getRowData(ctx.previousId);
|
50
|
-
if (row) {
|
51
|
-
if (row["ROW_DEF"]) {
|
52
|
-
row["ROW_DEF"].setData(ctx.field, false);
|
53
|
-
} else {
|
54
|
-
dv.setData(ctx.previousId, ctx.field, false);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
ctx.previousId = dv.getRowId(ctx.rowIndex);
|
99
|
+
ctx.selectRadio(ctx.rowIndex, true);
|
59
100
|
};
|
60
101
|
|
61
102
|
/** @constructor
|
@@ -76,6 +117,7 @@ EFRadioButtonFormatter.create = function (options) {
|
|
76
117
|
styles: {
|
77
118
|
margin: 0
|
78
119
|
},
|
120
|
+
selectRadio: _selectRadio,
|
79
121
|
onElementCreated: onElementCreated,
|
80
122
|
onElementUpdated: onElementUpdated,
|
81
123
|
changeHook: "checked-changed",
|
package/lib/grid/index.js
CHANGED
package/lib/versions.json
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
"tr-grid-rowcoloring": "1.0.26",
|
31
31
|
"tr-grid-textformatting": "1.0.49",
|
32
32
|
"tr-grid-titlewrap": "1.0.22",
|
33
|
-
"@grid/formatters": "1.0.
|
33
|
+
"@grid/formatters": "1.0.56",
|
34
34
|
"@grid/column-selection-dialog": "4.0.59",
|
35
35
|
"@grid/filter-dialog": "4.0.79",
|
36
36
|
"@grid/column-format-dialog": "4.0.45"
|
package/package.json
CHANGED