@refinitiv-ui/efx-grid 6.0.41 → 6.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/column-format-dialog/lib/column-format-dialog.d.ts +1 -0
- package/lib/column-format-dialog/lib/column-format-dialog.js +3 -24
- package/lib/column-format-dialog/lib/preview-table.d.ts +1 -1
- package/lib/column-format-dialog/lib/preview-table.js +15 -27
- package/lib/core/dist/core.js +843 -871
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.d.ts +4 -0
- package/lib/core/es6/grid/Core.js +67 -2
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +3 -2
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +32 -26
- package/lib/core/es6/grid/util/util.js +25 -9
- package/lib/formatters/es6/CoralButtonFormatter.d.ts +2 -2
- package/lib/formatters/es6/CoralCheckboxFormatter.d.ts +1 -1
- package/lib/formatters/es6/CoralComboBoxFormatter.d.ts +4 -4
- package/lib/formatters/es6/CoralIconFormatter.d.ts +3 -3
- package/lib/formatters/es6/CoralInputFormatter.d.ts +1 -1
- package/lib/formatters/es6/CoralRadioButtonFormatter.d.ts +2 -2
- package/lib/formatters/es6/CoralSelectFormatter.d.ts +4 -4
- package/lib/formatters/es6/CoralToggleFormatter.d.ts +1 -1
- package/lib/formatters/es6/DuplexEmeraldDateTimePickerFormatter.d.ts +1 -1
- package/lib/formatters/es6/EFButtonFormatter.d.ts +2 -2
- package/lib/formatters/es6/EFCheckboxFormatter.d.ts +1 -1
- package/lib/formatters/es6/EFComboBoxFormatter.d.ts +4 -4
- package/lib/formatters/es6/EFDateTimePickerFormatter.d.ts +1 -1
- package/lib/formatters/es6/EFIconFormatter.d.ts +3 -3
- package/lib/formatters/es6/EFNumberFieldFormatter.d.ts +1 -1
- package/lib/formatters/es6/EFRadioButtonFormatter.d.ts +2 -2
- package/lib/formatters/es6/EFSelectFormatter.d.ts +4 -4
- package/lib/formatters/es6/EFTextFieldFormatter.d.ts +1 -1
- package/lib/formatters/es6/EFToggleFormatter.d.ts +1 -1
- package/lib/formatters/es6/EmeraldDateTimePickerFormatter.d.ts +1 -1
- package/lib/formatters/es6/FormatterBuilder.d.ts +6 -2
- package/lib/formatters/es6/FormatterBuilder.js +328 -178
- package/lib/formatters/es6/NumericInputFormatter.d.ts +1 -1
- package/lib/formatters/es6/PercentBarFormatter.d.ts +6 -6
- package/lib/formatters/es6/SimpleImageFormatter.d.ts +3 -3
- package/lib/formatters/es6/SimpleInputFormatter.d.ts +1 -1
- package/lib/formatters/es6/SimpleLinkFormatter.d.ts +3 -3
- package/lib/formatters/es6/SimpleTickerFormatter.d.ts +3 -3
- package/lib/formatters/es6/SimpleToggleFormatter.d.ts +3 -3
- package/lib/formatters/es6/TextFormatter.d.ts +1 -1
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +213 -44
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.d.ts +24 -1
- package/lib/rt-grid/es6/Grid.js +92 -4
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +4 -0
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +34 -19
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +9 -3
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +324 -388
- package/lib/tr-grid-filter-input/es6/FilterInput.d.ts +17 -17
- package/lib/tr-grid-filter-input/es6/FilterInput.js +146 -33
- package/lib/tr-grid-util/es6/DateTime.js +3 -3
- package/lib/tr-grid-util/es6/GridPlugin.js +1 -1
- package/lib/types/es6/ColumnGrouping.d.ts +4 -0
- package/lib/types/es6/ColumnStack.d.ts +9 -3
- package/lib/types/es6/CoralButtonFormatter.d.ts +2 -2
- package/lib/types/es6/CoralCheckboxFormatter.d.ts +1 -1
- package/lib/types/es6/CoralComboBoxFormatter.d.ts +4 -4
- package/lib/types/es6/CoralIconFormatter.d.ts +3 -3
- package/lib/types/es6/CoralInputFormatter.d.ts +1 -1
- package/lib/types/es6/CoralRadioButtonFormatter.d.ts +2 -2
- package/lib/types/es6/CoralSelectFormatter.d.ts +4 -4
- package/lib/types/es6/CoralToggleFormatter.d.ts +1 -1
- package/lib/types/es6/Core/grid/Core.d.ts +4 -0
- package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +3 -2
- package/lib/types/es6/DuplexEmeraldDateTimePickerFormatter.d.ts +1 -1
- package/lib/types/es6/EFButtonFormatter.d.ts +2 -2
- package/lib/types/es6/EFCheckboxFormatter.d.ts +1 -1
- package/lib/types/es6/EFComboBoxFormatter.d.ts +4 -4
- package/lib/types/es6/EFDateTimePickerFormatter.d.ts +1 -1
- package/lib/types/es6/EFIconFormatter.d.ts +3 -3
- package/lib/types/es6/EFNumberFieldFormatter.d.ts +1 -1
- package/lib/types/es6/EFRadioButtonFormatter.d.ts +2 -2
- package/lib/types/es6/EFSelectFormatter.d.ts +4 -4
- package/lib/types/es6/EFTextFieldFormatter.d.ts +1 -1
- package/lib/types/es6/EFToggleFormatter.d.ts +1 -1
- package/lib/types/es6/EmeraldDateTimePickerFormatter.d.ts +1 -1
- package/lib/types/es6/FilterInput.d.ts +17 -17
- package/lib/types/es6/FormatterBuilder.d.ts +6 -2
- package/lib/types/es6/NumericInputFormatter.d.ts +1 -1
- package/lib/types/es6/PercentBarFormatter.d.ts +6 -6
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +22 -0
- package/lib/types/es6/SimpleImageFormatter.d.ts +3 -3
- package/lib/types/es6/SimpleInputFormatter.d.ts +1 -1
- package/lib/types/es6/SimpleLinkFormatter.d.ts +3 -3
- package/lib/types/es6/SimpleTickerFormatter.d.ts +3 -3
- package/lib/types/es6/SimpleToggleFormatter.d.ts +3 -3
- package/lib/types/es6/TextFormatter.d.ts +1 -1
- package/lib/versions.json +6 -6
- package/package.json +1 -1
|
@@ -1,152 +1,235 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
/** @typedef {Object} FormatterBuilder~Options
|
|
4
2
|
* @description FormatterBuilder options
|
|
3
|
+
* @property {string=} field
|
|
5
4
|
* @property {Object=} attributes
|
|
6
5
|
* @property {Object=} styles
|
|
7
6
|
* @property {Object=} events
|
|
7
|
+
* @property {Function=} changeHandler
|
|
8
|
+
* @property {Array.<Function>=} changeHandlers
|
|
9
|
+
* @property {Function=} onElementRendered
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
12
|
/** Dictionary that contain reserved attribute to context element
|
|
11
|
-
* @type {
|
|
13
|
+
* @type {!Object}
|
|
12
14
|
* @private
|
|
15
|
+
* @constant
|
|
13
16
|
*/
|
|
14
|
-
var
|
|
17
|
+
var ReservedAttributes = {
|
|
15
18
|
"api": true,
|
|
16
|
-
"wrapper": true,
|
|
19
|
+
"wrapper": true, // wrapper is generated during runtime binding
|
|
17
20
|
"grid": true,
|
|
18
21
|
"field": true,
|
|
19
22
|
"rowIndex": true,
|
|
20
23
|
"value": true,
|
|
21
24
|
"setData": true,
|
|
22
25
|
"getData": true,
|
|
26
|
+
"disableElement": true,
|
|
27
|
+
"isElementDisabled": true,
|
|
28
|
+
"setError": true,
|
|
29
|
+
"getError": true,
|
|
23
30
|
"styles": true,
|
|
24
31
|
"attributes": true,
|
|
25
|
-
"tagName": true,
|
|
32
|
+
"tagName": true, // for internal use only
|
|
33
|
+
"refName": true, // for internal use only
|
|
26
34
|
"events": true,
|
|
27
|
-
"userEvents": true,
|
|
28
|
-
"defaultEvents": true,
|
|
29
|
-
"onContextCreated": true,
|
|
30
|
-
"onElementCreated": true,
|
|
31
|
-
"onElementUpdated": true,
|
|
32
|
-
"
|
|
33
|
-
"
|
|
35
|
+
"userEvents": true, // for internal use only
|
|
36
|
+
"defaultEvents": true, // for internal use only
|
|
37
|
+
"onContextCreated": true, // for internal use only
|
|
38
|
+
"onElementCreated": true, // for internal use only
|
|
39
|
+
"onElementUpdated": true, // for internal use only
|
|
40
|
+
"onElementRendered": true,
|
|
41
|
+
"changeHook": true, // for internal use only
|
|
42
|
+
"changeHooks": true, // for internal use only
|
|
43
|
+
"changeHandler": true,
|
|
44
|
+
"changeHandlers": true
|
|
34
45
|
};
|
|
35
46
|
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
/** Clone all non-reserved properties from master to base
|
|
48
|
+
* @private
|
|
49
|
+
* @function
|
|
50
|
+
* @param {Object} base Base object
|
|
51
|
+
* @param {Object} master Master object. There will be no modification on this object
|
|
52
|
+
*/
|
|
53
|
+
function _assignProperties(base, master) {
|
|
54
|
+
for (var key in master) {
|
|
55
|
+
if (!ReservedAttributes[key]) {
|
|
56
|
+
base[key] = master[key];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
38
59
|
}
|
|
60
|
+
/** Clone a property with Object map from master to base
|
|
61
|
+
* @private
|
|
62
|
+
* @function
|
|
63
|
+
* @param {Object} base Base object
|
|
64
|
+
* @param {Object} master Master object. There will be no modification on this object
|
|
65
|
+
* @returns {boolean} Returns true, if there is any change
|
|
66
|
+
*/
|
|
67
|
+
function _assignAttributes(base, master) {
|
|
68
|
+
var mObj = master.attributes;
|
|
69
|
+
if(!mObj) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
39
72
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
73
|
+
var dirty = false;
|
|
74
|
+
var bObj = base.attributes;
|
|
75
|
+
if(!bObj) {
|
|
76
|
+
bObj = {};
|
|
77
|
+
}
|
|
78
|
+
for(var key in mObj) {
|
|
79
|
+
dirty = true;
|
|
80
|
+
bObj[key] = mObj[key];
|
|
81
|
+
}
|
|
82
|
+
if(!dirty) {
|
|
83
|
+
return false;
|
|
44
84
|
}
|
|
85
|
+
|
|
86
|
+
if(!base.attributes) {
|
|
87
|
+
base.attributes = bObj;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
45
90
|
}
|
|
91
|
+
/** Clone a property with Object map from master to base
|
|
92
|
+
* @private
|
|
93
|
+
* @function
|
|
94
|
+
* @param {Object} base Base object
|
|
95
|
+
* @param {Object} master Master object. There will be no modification on this object
|
|
96
|
+
* @returns {boolean} Returns true, if there is any change
|
|
97
|
+
*/
|
|
98
|
+
function _assignStyles(base, master) {
|
|
99
|
+
var mObj = master.styles;
|
|
100
|
+
if(!mObj) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
46
103
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
104
|
+
var dirty = false;
|
|
105
|
+
var bObj = base.styles;
|
|
106
|
+
if(!bObj) {
|
|
107
|
+
bObj = {};
|
|
108
|
+
}
|
|
109
|
+
for(var key in mObj) {
|
|
110
|
+
dirty = true;
|
|
111
|
+
var val = mObj[key];
|
|
112
|
+
if(key === "width" || key === "height") {
|
|
113
|
+
if(typeof val === "number") {
|
|
114
|
+
val = val + "px";
|
|
55
115
|
}
|
|
56
|
-
fn(name, val);
|
|
57
116
|
}
|
|
117
|
+
bObj[key] = val;
|
|
118
|
+
}
|
|
119
|
+
if(!dirty) {
|
|
120
|
+
return false;
|
|
58
121
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function assignAttribute(text, options, defaultOpt) {
|
|
62
|
-
forEachSetProperties(defaultOpt.attributes, function (name, val) {
|
|
63
|
-
text.push(' element.setAttribute("' + name + '", "' + val + '");');
|
|
64
|
-
});
|
|
65
122
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
123
|
+
if(!base.styles) {
|
|
124
|
+
base.styles = bObj;
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
69
127
|
}
|
|
70
128
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
129
|
+
/** @private
|
|
130
|
+
* @function
|
|
131
|
+
* @param {Object} ctx
|
|
132
|
+
* @param {Function} userFunc
|
|
133
|
+
* @param {Object} e
|
|
134
|
+
*/
|
|
135
|
+
function _positionLocator(ctx, userFunc, e) {
|
|
136
|
+
if (!ctx.grid.isBinding()) {
|
|
137
|
+
ctx.grid.getRelativePosition(e, ctx);
|
|
138
|
+
userFunc(e, ctx);
|
|
139
|
+
}
|
|
79
140
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
141
|
+
/** Clone event listerners from master to base
|
|
142
|
+
* @private
|
|
143
|
+
* @function
|
|
144
|
+
* @param {Object} base Base object
|
|
145
|
+
* @param {Object} master Master object. There will be no modification on this object
|
|
146
|
+
* @param {string} optionType
|
|
147
|
+
* @returns {boolean} Returns true, if there is any change
|
|
148
|
+
*/
|
|
149
|
+
function _assignListener(base, master, optionType) {
|
|
150
|
+
var mObj = master.events;
|
|
151
|
+
if(!mObj) {
|
|
152
|
+
return false;
|
|
88
153
|
}
|
|
89
154
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
155
|
+
var dirty = false;
|
|
156
|
+
var bObj = base[optionType];
|
|
157
|
+
if(!bObj) {
|
|
158
|
+
bObj = {};
|
|
159
|
+
}
|
|
160
|
+
for (var key in mObj) {
|
|
161
|
+
var func = mObj[key];
|
|
162
|
+
if (typeof func === "function") {
|
|
163
|
+
dirty = true;
|
|
164
|
+
bObj[key] = _positionLocator.bind(null, base, func);
|
|
94
165
|
}
|
|
95
166
|
}
|
|
167
|
+
if(!dirty) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if(!base[optionType]) {
|
|
171
|
+
base[optionType] = bObj;
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
96
174
|
}
|
|
97
175
|
|
|
98
|
-
|
|
99
176
|
/** @private
|
|
100
|
-
* @
|
|
177
|
+
* @param {Object} ctx
|
|
101
178
|
* @param {Object} colDef User's column definition object
|
|
102
179
|
* @param {tr.Grid} grid Core grid instance
|
|
103
180
|
*/
|
|
104
|
-
function _onInitContextObject(colDef, grid) { // Executed once per column
|
|
105
|
-
|
|
106
|
-
if (!
|
|
107
|
-
|
|
108
|
-
if(
|
|
109
|
-
|
|
181
|
+
function _onInitContextObject(ctx, colDef, grid) { // Executed once per column
|
|
182
|
+
ctx.grid = grid; // WARNING: using ctx as closure variable
|
|
183
|
+
if (!ctx.field) {
|
|
184
|
+
ctx.field = colDef.field;
|
|
185
|
+
if(ctx.disablingField == null) {
|
|
186
|
+
ctx.disablingField = ctx.field ? ctx.field + "_DISABLED" : null;
|
|
110
187
|
}
|
|
111
|
-
if(
|
|
112
|
-
|
|
188
|
+
if(ctx.errorField == null) {
|
|
189
|
+
ctx.errorField = ctx.field ? ctx.field + "_ERROR" : null;
|
|
113
190
|
}
|
|
114
191
|
}
|
|
115
192
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
this.setError = _setError;
|
|
121
|
-
this.getError = _getError;
|
|
193
|
+
ctx.disableElement = _disableElement;
|
|
194
|
+
ctx.isElementDisabled = _isElementDisabled;
|
|
195
|
+
ctx.setError = _setError;
|
|
196
|
+
ctx.getError = _getError;
|
|
122
197
|
}
|
|
123
198
|
/** @private
|
|
124
199
|
* @this ContextObject
|
|
125
200
|
* @param {string} field
|
|
126
201
|
* @param {*} value
|
|
127
202
|
*/
|
|
128
|
-
function
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
rowDef.setStaticData(field, value);
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
this.api.getDataView().setDataAt(this.rowIndex, field, value); // WARNING: Use of closure variable
|
|
203
|
+
function _setRtGridData(field, value) {
|
|
204
|
+
var rowDef = this.api.getRowDefinition(this.rowIndex);
|
|
205
|
+
if(rowDef) {
|
|
206
|
+
rowDef.setStaticData(field, value);
|
|
136
207
|
}
|
|
137
208
|
}
|
|
138
209
|
/** @private
|
|
139
210
|
* @this ContextObject
|
|
140
211
|
* @param {boolean} field
|
|
141
|
-
* @
|
|
212
|
+
* @returns {*} Value
|
|
142
213
|
*/
|
|
143
|
-
function
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
214
|
+
function _getRtGridData(field) {
|
|
215
|
+
var rowDef = this.api.getRowDefinition(this.rowIndex);
|
|
216
|
+
return rowDef ? rowDef.getData(field) : null;
|
|
217
|
+
}
|
|
218
|
+
/** @private
|
|
219
|
+
* @this ContextObject
|
|
220
|
+
* @param {string} field
|
|
221
|
+
* @param {*} value
|
|
222
|
+
*/
|
|
223
|
+
function _setCoreGridData(field, value) {
|
|
224
|
+
this.api.getDataView().setDataAt(this.rowIndex, field, value);
|
|
225
|
+
}
|
|
226
|
+
/** @private
|
|
227
|
+
* @this ContextObject
|
|
228
|
+
* @param {boolean} field
|
|
229
|
+
* @returns {*} Value
|
|
230
|
+
*/
|
|
231
|
+
function _getCoreGridData(field) {
|
|
232
|
+
return this.api.getDataView().getDataAt(this.rowIndex, field);
|
|
150
233
|
}
|
|
151
234
|
/** @private
|
|
152
235
|
* @this ContextObject
|
|
@@ -159,7 +242,7 @@ function _disableElement(bool) {
|
|
|
159
242
|
}
|
|
160
243
|
/** @private
|
|
161
244
|
* @this ContextObject
|
|
162
|
-
* @
|
|
245
|
+
* @returns {boolean}
|
|
163
246
|
*/
|
|
164
247
|
function _isElementDisabled() {
|
|
165
248
|
return this.getData(this.disablingField);
|
|
@@ -175,104 +258,181 @@ function _setError(val) {
|
|
|
175
258
|
}
|
|
176
259
|
/** @private
|
|
177
260
|
* @this ContextObject
|
|
178
|
-
* @
|
|
261
|
+
* @returns {*}
|
|
179
262
|
*/
|
|
180
263
|
function _getError() {
|
|
181
264
|
return this.getData(this.errorField);
|
|
182
265
|
}
|
|
183
266
|
|
|
267
|
+
/** @private
|
|
268
|
+
* @function
|
|
269
|
+
* @param {Object} ctx
|
|
270
|
+
* @param {Object} e
|
|
271
|
+
*/
|
|
272
|
+
function _predefinedBinding(ctx, e) {
|
|
273
|
+
ctx.api = e["grid"];
|
|
274
|
+
if(!ctx.wrapper) {
|
|
275
|
+
ctx.wrapper = "real-time-grid";
|
|
276
|
+
ctx.setData = _setRtGridData;
|
|
277
|
+
ctx.getData = _getRtGridData;
|
|
278
|
+
}
|
|
279
|
+
var rowData = ctx.rowData = e["rowData"];
|
|
280
|
+
if(ctx.field) {
|
|
281
|
+
ctx.value = rowData ? rowData[ctx.field] : null;
|
|
282
|
+
} else {
|
|
283
|
+
ctx.value = e["data"];
|
|
284
|
+
}
|
|
285
|
+
ctx.rowIndex = e["rowIndex"];
|
|
286
|
+
ctx.colIndex = e["colIndex"];
|
|
287
|
+
ctx.cell = e["cell"];
|
|
184
288
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
289
|
+
_commonBinding(ctx);
|
|
290
|
+
}
|
|
291
|
+
/** @private
|
|
292
|
+
* @function
|
|
293
|
+
* @param {Object} ctx
|
|
294
|
+
* @param {number} rowIndex
|
|
295
|
+
* @param {number} columnIndex
|
|
296
|
+
* @param {*} value
|
|
297
|
+
* @param {Object} cell
|
|
298
|
+
* @param {Object} colDef
|
|
299
|
+
* @param {Object} dataRow
|
|
300
|
+
* @param {Object} dataTable
|
|
301
|
+
* @param {Object} dataView
|
|
302
|
+
* @param {Object} cgrid
|
|
303
|
+
*/
|
|
304
|
+
function _predefinedFormatter(ctx, rowIndex, columnIndex, value, cell, colDef, dataRow, dataTable, dataView, cgrid) {
|
|
305
|
+
ctx.api = cgrid;
|
|
306
|
+
if(!ctx.wrapper) {
|
|
307
|
+
ctx.wrapper = "composite-grid";
|
|
308
|
+
ctx.setData = _setCoreGridData;
|
|
309
|
+
ctx.getData = _getCoreGridData;
|
|
190
310
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
311
|
+
var rowData = ctx.rowData = dataRow;
|
|
312
|
+
if (ctx.field) {
|
|
313
|
+
ctx.value = rowData ? rowData[ctx.field] : null;
|
|
314
|
+
} else {
|
|
315
|
+
ctx.value = value;
|
|
195
316
|
}
|
|
317
|
+
ctx.rowIndex = rowIndex;
|
|
318
|
+
ctx.colIndex = columnIndex;
|
|
319
|
+
ctx.cell = cell;
|
|
196
320
|
|
|
197
|
-
|
|
198
|
-
|
|
321
|
+
_commonBinding(ctx);
|
|
322
|
+
}
|
|
323
|
+
/** @private
|
|
324
|
+
* @function
|
|
325
|
+
* @param {Object} ctx
|
|
326
|
+
*/
|
|
327
|
+
function _commonBinding(ctx) {
|
|
328
|
+
var elem = ctx.cell.getContent();
|
|
329
|
+
if(!elem || (elem._formatterName !== ctx.refName)) {
|
|
330
|
+
elem = document.createElement(ctx.tagName);
|
|
331
|
+
elem._formatterName = ctx.refName;
|
|
332
|
+
if (ctx.onElementCreated) {
|
|
333
|
+
ctx.onElementCreated(elem, ctx);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
var attrs = ctx.attributes;
|
|
337
|
+
if(attrs) {
|
|
338
|
+
for(var attrName in attrs) {
|
|
339
|
+
elem.setAttribute(attrName, attrs[attrName] || "");
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
var stys = ctx.styles;
|
|
344
|
+
if(stys) {
|
|
345
|
+
for(var styName in stys) {
|
|
346
|
+
elem.style[styName] = stys[styName];
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
var evts, evtName;
|
|
351
|
+
evts = ctx.defaultEvents;
|
|
352
|
+
if(evts) {
|
|
353
|
+
for (evtName in evts) {
|
|
354
|
+
elem.addEventListener(
|
|
355
|
+
evtName,
|
|
356
|
+
evts[evtName]
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
evts = ctx.userEvents;
|
|
361
|
+
if(evts) {
|
|
362
|
+
for (evtName in evts) {
|
|
363
|
+
elem.addEventListener(
|
|
364
|
+
evtName,
|
|
365
|
+
evts[evtName]
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
199
369
|
}
|
|
200
370
|
|
|
201
|
-
var
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
text.push(' ctx.api = e["grid"];');
|
|
206
|
-
text.push(' ctx.wrapper = "real-time-grid";');
|
|
207
|
-
if (options.field) {
|
|
208
|
-
text.push(' ctx.value = e["rowData"][ctx.field];');
|
|
371
|
+
var rowData = ctx.rowData;
|
|
372
|
+
if(ctx.disablingField) {
|
|
373
|
+
if(rowData && rowData[ctx.disablingField]){
|
|
374
|
+
elem.setAttribute("disabled", "");
|
|
209
375
|
} else {
|
|
210
|
-
|
|
376
|
+
elem.removeAttribute("disabled");
|
|
211
377
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
text.push('(function(rowIndex, columnIndex, value, cell, colDef, dataRow, dataTable, dataView, cgrid) {');
|
|
217
|
-
text.push(' ctx.api = cgrid;');
|
|
218
|
-
text.push(' ctx.wrapper = "composite-grid";');
|
|
219
|
-
if (options.field) {
|
|
220
|
-
text.push(' ctx.value = dataRow ? dataRow[ctx.field] : null;');
|
|
378
|
+
}
|
|
379
|
+
if(ctx.errorField) {
|
|
380
|
+
if(rowData && rowData[ctx.errorField]){
|
|
381
|
+
elem.setAttribute("error", "");
|
|
221
382
|
} else {
|
|
222
|
-
|
|
383
|
+
elem.removeAttribute("error");
|
|
223
384
|
}
|
|
224
|
-
text.push(' ctx.rowIndex = rowIndex;');
|
|
225
|
-
text.push(' ctx.colIndex = columnIndex;');
|
|
226
|
-
text.push(' ctx.cell = cell;');
|
|
227
385
|
}
|
|
228
386
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
ctx.onElementCreated = defaultOpt.onElementCreated;
|
|
236
|
-
text.push(' ctx.onElementCreated(element, ctx);');
|
|
387
|
+
if(ctx.onElementUpdated) {
|
|
388
|
+
ctx.onElementUpdated(elem, ctx);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (ctx.onElementRendered) {
|
|
392
|
+
ctx.onElementRendered(elem, ctx);
|
|
237
393
|
}
|
|
238
394
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
assignListener(text, options, defaultOpt);
|
|
395
|
+
ctx.cell.setContent(elem);
|
|
396
|
+
}
|
|
242
397
|
|
|
243
|
-
|
|
398
|
+
/** @private
|
|
399
|
+
* @function
|
|
400
|
+
* @param {Object} ctx Context object
|
|
401
|
+
* @param {Object} userOpt User options
|
|
402
|
+
* @param {Object} defaultOpt Default options
|
|
403
|
+
*/
|
|
404
|
+
function _buildContextObject(ctx, userOpt, defaultOpt) {
|
|
405
|
+
_assignProperties(ctx, defaultOpt);
|
|
406
|
+
_assignProperties(ctx, userOpt);
|
|
244
407
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
text.push(' if(ctx.getError()) {');
|
|
254
|
-
text.push(' element.setAttribute("error", "");');
|
|
255
|
-
text.push(' } else {');
|
|
256
|
-
text.push(' element.removeAttribute("error");');
|
|
257
|
-
text.push(' }');
|
|
258
|
-
}
|
|
408
|
+
_assignAttributes(ctx, defaultOpt);
|
|
409
|
+
_assignAttributes(ctx, userOpt);
|
|
410
|
+
|
|
411
|
+
_assignStyles(ctx, defaultOpt);
|
|
412
|
+
_assignStyles(ctx, userOpt);
|
|
413
|
+
|
|
414
|
+
_assignListener(ctx, defaultOpt, "defaultEvents");
|
|
415
|
+
_assignListener(ctx, userOpt, "userEvents");
|
|
259
416
|
|
|
260
|
-
|
|
417
|
+
ctx.field = userOpt.field || "";
|
|
418
|
+
ctx.refName = defaultOpt.refName || "_defaultFormatter";
|
|
419
|
+
ctx.tagName = defaultOpt.tagName || "div";
|
|
420
|
+
|
|
421
|
+
if (defaultOpt.onElementCreated) {
|
|
422
|
+
ctx.onElementCreated = defaultOpt.onElementCreated;
|
|
423
|
+
}
|
|
261
424
|
if (defaultOpt.onElementUpdated) {
|
|
262
425
|
ctx.onElementUpdated = defaultOpt.onElementUpdated;
|
|
263
|
-
text.push(' ctx.onElementUpdated(element, ctx);');
|
|
264
426
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
ctx.onElementRendered = options.onElementRendered;
|
|
268
|
-
text.push(' ctx.onElementRendered(element, ctx);');
|
|
427
|
+
if (typeof userOpt.onElementRendered === "function") {
|
|
428
|
+
ctx.onElementRendered = userOpt.onElementRendered;
|
|
269
429
|
}
|
|
270
|
-
|
|
271
|
-
text.push(' cell.setContent(element);');
|
|
272
|
-
text.push('})');
|
|
273
|
-
return text.filter(Boolean).join('\n');
|
|
274
430
|
}
|
|
275
431
|
|
|
432
|
+
/** @private
|
|
433
|
+
*/
|
|
434
|
+
function _emptyFunc() {}
|
|
435
|
+
|
|
276
436
|
/** @constructor
|
|
277
437
|
* @param {*=} options
|
|
278
438
|
*/
|
|
@@ -288,8 +448,6 @@ var FormatterBuilder = function (options) {
|
|
|
288
448
|
FormatterBuilder.create = function (userOptions, defaultOpt) {
|
|
289
449
|
userOptions = userOptions || {};
|
|
290
450
|
defaultOpt = defaultOpt || {};
|
|
291
|
-
var ctx = {}; // WANRING: This object is used as a closure variable
|
|
292
|
-
ctx.field = userOptions.field;
|
|
293
451
|
|
|
294
452
|
if (defaultOpt.changeHook) {
|
|
295
453
|
var changeHandler = userOptions.changeHandler || defaultOpt.changeHandler;
|
|
@@ -307,26 +465,18 @@ FormatterBuilder.create = function (userOptions, defaultOpt) {
|
|
|
307
465
|
}
|
|
308
466
|
}
|
|
309
467
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
468
|
+
var ctx = {};
|
|
469
|
+
_buildContextObject(ctx, userOptions, defaultOpt);
|
|
313
470
|
|
|
314
|
-
if (
|
|
315
|
-
ctx
|
|
471
|
+
if (defaultOpt.onContextCreated) {
|
|
472
|
+
defaultOpt.onContextCreated(ctx, userOptions);
|
|
316
473
|
}
|
|
317
474
|
|
|
318
|
-
var txt;
|
|
319
|
-
txt = buildFnText("composite-grid", ctx, userOptions, defaultOpt);
|
|
320
|
-
var compositeGridBinding = eval(txt);
|
|
321
|
-
|
|
322
|
-
txt = buildFnText("real-time-grid", ctx, userOptions, defaultOpt);
|
|
323
|
-
var rtGridBinding = eval(txt);
|
|
324
|
-
|
|
325
475
|
return {
|
|
326
|
-
render:
|
|
327
|
-
init: _onInitContextObject.bind(ctx),
|
|
328
|
-
bind:
|
|
329
|
-
binding:
|
|
476
|
+
render: _emptyFunc,
|
|
477
|
+
init: _onInitContextObject.bind(null, ctx),
|
|
478
|
+
bind: _predefinedFormatter.bind(null, ctx),
|
|
479
|
+
binding: _predefinedBinding.bind(null, ctx)
|
|
330
480
|
};
|
|
331
481
|
};
|
|
332
482
|
|
|
@@ -4,11 +4,11 @@ import {PercentBar} from "../../tr-grid-util/es6/PercentBar.js";
|
|
|
4
4
|
declare namespace PercentBarFormatter {
|
|
5
5
|
|
|
6
6
|
type Options = {
|
|
7
|
-
alignment?: string,
|
|
8
|
-
movementColor?: boolean,
|
|
9
|
-
barColor?: string,
|
|
10
|
-
textHidden?: boolean,
|
|
11
|
-
textWidth?: (number|string)
|
|
7
|
+
alignment?: string|null,
|
|
8
|
+
movementColor?: boolean|null,
|
|
9
|
+
barColor?: string|null,
|
|
10
|
+
textHidden?: boolean|null,
|
|
11
|
+
textWidth?: (number|string)|null
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
}
|
|
@@ -17,7 +17,7 @@ declare class PercentBarFormatter {
|
|
|
17
17
|
|
|
18
18
|
constructor(options?: any);
|
|
19
19
|
|
|
20
|
-
public static create(options?: (FormatterBuilder.Options|PercentBarFormatter.Options|any)): any;
|
|
20
|
+
public static create(options?: (FormatterBuilder.Options|PercentBarFormatter.Options|any)|null): any;
|
|
21
21
|
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -3,8 +3,8 @@ import FormatterBuilder from "./FormatterBuilder.js";
|
|
|
3
3
|
declare namespace SimpleImageFormatter {
|
|
4
4
|
|
|
5
5
|
type Options = {
|
|
6
|
-
height?: (string|number),
|
|
7
|
-
width?: (string|number)
|
|
6
|
+
height?: (string|number)|null,
|
|
7
|
+
width?: (string|number)|null
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
}
|
|
@@ -13,7 +13,7 @@ declare class SimpleImageFormatter {
|
|
|
13
13
|
|
|
14
14
|
constructor(options?: any);
|
|
15
15
|
|
|
16
|
-
public static create(options?: (FormatterBuilder.Options|SimpleImageFormatter.Options|any)): any;
|
|
16
|
+
public static create(options?: (FormatterBuilder.Options|SimpleImageFormatter.Options|any)|null): any;
|
|
17
17
|
|
|
18
18
|
}
|
|
19
19
|
|