jsl-ui 9.12.1 → 9.13.2
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/components/IntervalComponent.js +10 -10
- package/lib/core/jq.js +6 -0
- package/lib/grid/plugins/ext.overlay.css +28 -0
- package/lib/grid/plugins/ext.overlay.d.ts +2 -0
- package/lib/grid/plugins/ext.overlay.js +273 -0
- package/lib/grid/slick.core.d.ts +2 -2
- package/lib/grid/slick.creator.d.ts +2 -0
- package/lib/grid/slick.creator.js +66 -2
- package/lib/grid/slick.grid.d.ts +30 -0
- package/lib/index.css +29 -0
- package/lib/index.css.map +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -20,7 +20,16 @@ var IntervalComponent = /** @class */ (function () {
|
|
|
20
20
|
node.dom.value = "";
|
|
21
21
|
}
|
|
22
22
|
var f = function () {
|
|
23
|
-
var result
|
|
23
|
+
var result;
|
|
24
|
+
try {
|
|
25
|
+
result = _this.fnc();
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
console.error(e);
|
|
29
|
+
if (_this.options.stopOnError) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
24
33
|
var isPromise = result && typeof result.then === "function" && typeof result.catch === "function";
|
|
25
34
|
if (isPromise) {
|
|
26
35
|
result.then(function () {
|
|
@@ -39,15 +48,6 @@ var IntervalComponent = /** @class */ (function () {
|
|
|
39
48
|
});
|
|
40
49
|
}
|
|
41
50
|
else {
|
|
42
|
-
try {
|
|
43
|
-
_this.fnc();
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
console.error(e);
|
|
47
|
-
if (_this.options.stopOnError) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
51
|
if (!_this.options.noRefresh) {
|
|
52
52
|
_this.renderer.refresh();
|
|
53
53
|
}
|
package/lib/core/jq.js
CHANGED
|
@@ -43,6 +43,12 @@ function jQWrapper(elements) {
|
|
|
43
43
|
if (selector instanceof HTMLElement) {
|
|
44
44
|
selector.appendChild(_elements[i]);
|
|
45
45
|
}
|
|
46
|
+
else if (typeof (selector) === "string") {
|
|
47
|
+
var parents = document.querySelectorAll(selector);
|
|
48
|
+
for (var i_1 = 0, len = parents.length; i_1 < len; i_1++) {
|
|
49
|
+
parents[i_1].appendChild(_elements[i_1]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
46
52
|
else {
|
|
47
53
|
for (var j = 0; j < selector.length; j++) {
|
|
48
54
|
selector[j].appendChild(_elements[i]);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
.header-overlay {
|
|
3
|
+
background-color: #217346;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.cell-overlay,
|
|
7
|
+
.selection-cell-overlay {
|
|
8
|
+
display: block;
|
|
9
|
+
position: absolute;
|
|
10
|
+
z-index: 900;
|
|
11
|
+
background-color: #217346;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.handle-overlay {
|
|
15
|
+
border: 1px solid white;
|
|
16
|
+
padding: 3px;
|
|
17
|
+
background-color: #217346;
|
|
18
|
+
position: absolute;
|
|
19
|
+
width: 2px;
|
|
20
|
+
height: 2px;
|
|
21
|
+
z-index: 1000;
|
|
22
|
+
cursor: crosshair;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.overlay-handle-decorator {
|
|
26
|
+
border: 2px solid #217346;
|
|
27
|
+
z-index: 1000;
|
|
28
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import "./ext.overlay.css";
|
|
2
|
+
import { jQueryReplacement } from "../../core/jq";
|
|
3
|
+
import { Slick } from "../slick.core";
|
|
4
|
+
import { Moveable } from "../../interaction/moveable";
|
|
5
|
+
import { EventHandler } from "../../interaction/eventhandler";
|
|
6
|
+
var selectinOverlayWidth = 1;
|
|
7
|
+
var $ = jQueryReplacement;
|
|
8
|
+
// register namespace
|
|
9
|
+
$.deepExtend(window, {
|
|
10
|
+
"Ext": {
|
|
11
|
+
"Plugins": {
|
|
12
|
+
"Overlays": Overlays
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
export function Overlays(options) {
|
|
17
|
+
var $headerOverlay;
|
|
18
|
+
var $rowOverlay;
|
|
19
|
+
var selectionOverlay;
|
|
20
|
+
var currentColumn;
|
|
21
|
+
var handleDragging;
|
|
22
|
+
var grid;
|
|
23
|
+
var self = this;
|
|
24
|
+
var handler = new Slick.EventHandler();
|
|
25
|
+
var dragDecorator;
|
|
26
|
+
var defaults = {
|
|
27
|
+
buttonCssClass: null,
|
|
28
|
+
buttonImage: "../images/down.gif",
|
|
29
|
+
decoratorWidth: 2
|
|
30
|
+
};
|
|
31
|
+
function init(g) {
|
|
32
|
+
options = $.deepExtend({}, defaults, options);
|
|
33
|
+
grid = g;
|
|
34
|
+
dragDecorator = overlayRangeDecorator(grid);
|
|
35
|
+
$headerOverlay = createRowHeaderOverlay(100);
|
|
36
|
+
$rowOverlay = createRowHeaderOverlay(100);
|
|
37
|
+
selectionOverlay = createSelectionOverlay();
|
|
38
|
+
handler.subscribe(grid.onActiveCellChanged, activeCellChanged)
|
|
39
|
+
.subscribe(grid.onColumnsResized, columnResized)
|
|
40
|
+
.subscribe(grid.onScroll, gridScrolled);
|
|
41
|
+
}
|
|
42
|
+
function destroy() {
|
|
43
|
+
handler.unsubscribeAll();
|
|
44
|
+
}
|
|
45
|
+
function createRowHeaderOverlay(zIndex) {
|
|
46
|
+
return $(document.createElement("div"))
|
|
47
|
+
.addClass("header-overlay")
|
|
48
|
+
.css("position", "absolute")
|
|
49
|
+
.css("z-index", zIndex)
|
|
50
|
+
.appendTo(grid.getContainerNode());
|
|
51
|
+
}
|
|
52
|
+
function createSelectionOverlay() {
|
|
53
|
+
var canvas = grid.getCanvasNode();
|
|
54
|
+
var overlay = new Overlay(canvas, true);
|
|
55
|
+
return overlay;
|
|
56
|
+
}
|
|
57
|
+
function activeCellChanged(e, args) {
|
|
58
|
+
dragDecorator.hide();
|
|
59
|
+
moveSelectionOverlay(e, args);
|
|
60
|
+
moveHeaderRowOverlays(e, args);
|
|
61
|
+
}
|
|
62
|
+
function columnResized(e, args) {
|
|
63
|
+
moveHeaderRowOverlays(e, args);
|
|
64
|
+
moveSelectionOverlay(e, args);
|
|
65
|
+
}
|
|
66
|
+
function gridScrolled(e, args) {
|
|
67
|
+
moveHeaderRowOverlays(e, args);
|
|
68
|
+
moveSelectionOverlay(e, args);
|
|
69
|
+
}
|
|
70
|
+
function moveHeaderRowOverlays(e, args) {
|
|
71
|
+
if (typeof args.cell != 'undefined') {
|
|
72
|
+
currentColumn = args.cell;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if (!currentColumn) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!grid.getActiveCell()) {
|
|
80
|
+
$rowOverlay.css("display", "none");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
$rowOverlay.css("display", "");
|
|
84
|
+
var headerHeight = grid.getContainerNode().querySelector('.slick-header').getBoundingClientRect().height;
|
|
85
|
+
var cellPosition = grid.getActiveCellPosition();
|
|
86
|
+
var gridPosition = grid.getGridPosition();
|
|
87
|
+
$rowOverlay.css("display", cellPosition.visible ? "" : "none");
|
|
88
|
+
$headerOverlay.css("display", cellPosition.visible ? "" : "none");
|
|
89
|
+
var headerWidth = cellPosition.width;
|
|
90
|
+
$headerOverlay.css("left", (cellPosition.left - gridPosition.left) + "px").css("top", (headerHeight - 2) + "px").css("width", headerWidth + "px").css("height", "2px");
|
|
91
|
+
$rowOverlay.css("left", "0px").css("top", (cellPosition.top - gridPosition.top) + "px").css("width", "2px").css("height", cellPosition.height + "px");
|
|
92
|
+
}
|
|
93
|
+
function moveSelectionOverlay(e, args) {
|
|
94
|
+
var activeCell = grid.getActiveCell();
|
|
95
|
+
if (!activeCell) {
|
|
96
|
+
selectionOverlay.toggle(false);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
var column = grid.getColumns()[activeCell.cell];
|
|
100
|
+
selectionOverlay.toggle(true);
|
|
101
|
+
// Only show the handle if the cell is editable
|
|
102
|
+
selectionOverlay.handle.style.display = (column.editor != null && !column.readonly && grid.getOptions().editable) ? "" : "none";
|
|
103
|
+
var position = grid.getCellNodeBox(activeCell.row, activeCell.cell);
|
|
104
|
+
// Not coming through on the property so re-calculated
|
|
105
|
+
position.height = position.bottom - position.top;
|
|
106
|
+
position.width = position.right - position.left;
|
|
107
|
+
selectionOverlay.$left.css({
|
|
108
|
+
left: (position.left - selectinOverlayWidth) + "px",
|
|
109
|
+
top: position.top + "px",
|
|
110
|
+
width: selectinOverlayWidth + "px",
|
|
111
|
+
height: position.height + "px"
|
|
112
|
+
});
|
|
113
|
+
selectionOverlay.$right.css({
|
|
114
|
+
left: (position.left + position.width) + "px",
|
|
115
|
+
top: position.top + "px",
|
|
116
|
+
width: selectinOverlayWidth + "px",
|
|
117
|
+
height: position.height + "px"
|
|
118
|
+
});
|
|
119
|
+
selectionOverlay.$top.css({
|
|
120
|
+
left: (position.left - selectinOverlayWidth) + "px",
|
|
121
|
+
top: (position.top - selectinOverlayWidth) + "px",
|
|
122
|
+
width: (position.width + selectinOverlayWidth + 1) + "px",
|
|
123
|
+
height: selectinOverlayWidth + "px"
|
|
124
|
+
});
|
|
125
|
+
selectionOverlay.$bottom.css({
|
|
126
|
+
left: (position.left - selectinOverlayWidth) + "px",
|
|
127
|
+
top: (position.top + position.height) + "px",
|
|
128
|
+
width: (position.width + selectinOverlayWidth + 1) + "px",
|
|
129
|
+
height: selectinOverlayWidth + "px"
|
|
130
|
+
});
|
|
131
|
+
selectionOverlay.handle.style.left = (position.left + position.width - 4) + "px";
|
|
132
|
+
selectionOverlay.handle.style.top = (position.top + position.height - 4) + "px";
|
|
133
|
+
}
|
|
134
|
+
var dd_range;
|
|
135
|
+
function handleOverlayDragStart(e) {
|
|
136
|
+
var cell = grid.getActiveCell();
|
|
137
|
+
if (grid.canCellBeSelected(cell.row, cell.cell)) {
|
|
138
|
+
handleDragging = true;
|
|
139
|
+
}
|
|
140
|
+
if (!handleDragging) {
|
|
141
|
+
e.cancelEvent();
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
grid.focus();
|
|
145
|
+
dd_range = { start: cell, end: {} };
|
|
146
|
+
return dragDecorator.show(new Slick.Range(cell.row, cell.cell));
|
|
147
|
+
}
|
|
148
|
+
function handleOverlayDrag(e) {
|
|
149
|
+
if (!handleDragging) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
var end = {
|
|
153
|
+
cell: dd_range.start.cell, row: grid.getCellFromPoint(0, e.y).row - 1
|
|
154
|
+
};
|
|
155
|
+
if (!grid.canCellBeSelected(end.row, end.cell)) {
|
|
156
|
+
e.cancelEvent(); // ?
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
dd_range.end = end;
|
|
160
|
+
dragDecorator.show(new Slick.Range(dd_range.start.row, dd_range.start.cell, end.row, dd_range.start.cell));
|
|
161
|
+
}
|
|
162
|
+
function handleOverlayDragEnd(e) {
|
|
163
|
+
if (!handleDragging) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
handleDragging = false;
|
|
167
|
+
selectionOverlay.handle.style.display = "none";
|
|
168
|
+
self.onFillUpDown.notify({ "grid": grid, "range": dragDecorator.getSelectedRange(), direction: dd_range.end.row >= dd_range.start.row ? "down" : "up" }, e, self);
|
|
169
|
+
}
|
|
170
|
+
function Overlay(target, withHandel, prefix) {
|
|
171
|
+
var className = (prefix || '') + 'cell-overlay';
|
|
172
|
+
this.$left = $(document.createElement("div"))
|
|
173
|
+
.addClass(className)
|
|
174
|
+
.addClass('left')
|
|
175
|
+
.appendTo(target);
|
|
176
|
+
this.$right = $(document.createElement("div"))
|
|
177
|
+
.addClass(className)
|
|
178
|
+
.addClass('right')
|
|
179
|
+
.appendTo(target);
|
|
180
|
+
this.$top = $(document.createElement("div"))
|
|
181
|
+
.addClass(className)
|
|
182
|
+
.addClass('top')
|
|
183
|
+
.appendTo(target);
|
|
184
|
+
this.$bottom = $(document.createElement("div"))
|
|
185
|
+
.addClass(className)
|
|
186
|
+
.addClass('bottom')
|
|
187
|
+
.appendTo(target);
|
|
188
|
+
if (withHandel) {
|
|
189
|
+
this.handle = document.createElement("div");
|
|
190
|
+
this.handle.classList.add("handle-overlay");
|
|
191
|
+
target.appendChild(this.handle);
|
|
192
|
+
Moveable(target, {
|
|
193
|
+
selector: ".handle-overlay",
|
|
194
|
+
direction: "y",
|
|
195
|
+
gridY: grid.getOptions().rowHeight,
|
|
196
|
+
onStart: EventHandler.Create(function (e) {
|
|
197
|
+
handleOverlayDragStart(e);
|
|
198
|
+
}),
|
|
199
|
+
onMove: EventHandler.Create(function (e) {
|
|
200
|
+
handleOverlayDrag(e);
|
|
201
|
+
}),
|
|
202
|
+
onStop: EventHandler.Create(function (e) {
|
|
203
|
+
handleOverlayDragEnd(e);
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
this.toggle = function (showOrHide) {
|
|
208
|
+
this.$left.css("display", showOrHide ? "" : "none");
|
|
209
|
+
this.$right.css("display", showOrHide ? "" : "none");
|
|
210
|
+
this.$top.css("display", showOrHide ? "" : "none");
|
|
211
|
+
this.$bottom.css("display", showOrHide ? "" : "none");
|
|
212
|
+
if (this.handle) {
|
|
213
|
+
this.handle.style.display = showOrHide ? "" : "none";
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function overlayRangeDecorator(targetGrid) {
|
|
218
|
+
var decorator;
|
|
219
|
+
var r;
|
|
220
|
+
function show(range) {
|
|
221
|
+
r = range;
|
|
222
|
+
if (!decorator) {
|
|
223
|
+
decorator = new Overlay(grid.getCanvasNode(), false, 'selection-');
|
|
224
|
+
}
|
|
225
|
+
var from = targetGrid.getCellNodeBox(range.fromRow, range.fromCell);
|
|
226
|
+
var to = targetGrid.getCellNodeBox(range.toRow, range.toCell);
|
|
227
|
+
decorator.$left.css({
|
|
228
|
+
top: from.top - 2,
|
|
229
|
+
left: from.left - 2,
|
|
230
|
+
height: to.bottom - from.top + 2,
|
|
231
|
+
width: options.decoratorWidth
|
|
232
|
+
});
|
|
233
|
+
decorator.$right.css({
|
|
234
|
+
top: from.top - 2,
|
|
235
|
+
left: to.right - 1,
|
|
236
|
+
height: to.bottom - from.top + 2,
|
|
237
|
+
width: options.decoratorWidth
|
|
238
|
+
});
|
|
239
|
+
decorator.$top.css({
|
|
240
|
+
top: from.top - 2,
|
|
241
|
+
left: to.left - 1,
|
|
242
|
+
height: options.decoratorWidth,
|
|
243
|
+
width: to.right - from.left + 2
|
|
244
|
+
});
|
|
245
|
+
decorator.$bottom.css({
|
|
246
|
+
top: to.bottom - 1,
|
|
247
|
+
left: from.left - 2,
|
|
248
|
+
height: options.decoratorWidth,
|
|
249
|
+
width: to.right - from.left + 3
|
|
250
|
+
});
|
|
251
|
+
return decorator;
|
|
252
|
+
}
|
|
253
|
+
function getSelectedRange() {
|
|
254
|
+
return r;
|
|
255
|
+
}
|
|
256
|
+
function hide() {
|
|
257
|
+
if (decorator) {
|
|
258
|
+
decorator.toggle(false);
|
|
259
|
+
decorator = null;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
hide: hide,
|
|
264
|
+
show: show,
|
|
265
|
+
getSelectedRange: getSelectedRange
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
$.shallowExtend(this, {
|
|
269
|
+
"init": init,
|
|
270
|
+
"destroy": destroy,
|
|
271
|
+
"onFillUpDown": new Slick.Event()
|
|
272
|
+
});
|
|
273
|
+
}
|
package/lib/grid/slick.core.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface ISlick {
|
|
|
4
4
|
"Event": () => void;
|
|
5
5
|
"EventData": () => void;
|
|
6
6
|
"EventHandler": () => void;
|
|
7
|
-
"Range": (fromRow: number, fromCell: number, toRow
|
|
7
|
+
"Range": (fromRow: number, fromCell: number, toRow?: number, toCell?: number) => void;
|
|
8
8
|
"NonDataRow": () => void;
|
|
9
9
|
"Group": any;
|
|
10
10
|
"GroupTotals": any;
|
|
@@ -16,7 +16,7 @@ export interface ISlick {
|
|
|
16
16
|
}
|
|
17
17
|
export interface ISlickEvent<T> {
|
|
18
18
|
subscribe(fnc: (e: any, args: T) => any): any;
|
|
19
|
-
notify(
|
|
19
|
+
notify(args: T, e: any): any;
|
|
20
20
|
countHandlers(): number;
|
|
21
21
|
}
|
|
22
22
|
export interface ISlickFormatterResult {
|
|
@@ -16,6 +16,8 @@ export interface ISlickCreatorOptions extends ISlickGridOptions {
|
|
|
16
16
|
} | any[]>;
|
|
17
17
|
showFilterDialog?: (column: ISlickColumn, grid: IJSLGrid<any>) => void;
|
|
18
18
|
allowRowMove?: boolean;
|
|
19
|
+
enableFillDown?: boolean;
|
|
20
|
+
setDataItemValueForColumn?: (item: any, columnDef: ISlickColumn, value: any) => void;
|
|
19
21
|
}
|
|
20
22
|
export interface IJSLGrid<T> extends ISlickGrid<T> {
|
|
21
23
|
dataView: ISlickDataView<T>;
|
|
@@ -10,6 +10,7 @@ import { TextFormatter } from "./slick.formatters";
|
|
|
10
10
|
import { ExcelFilter } from "./filterDialogs/excelFilter";
|
|
11
11
|
import { UILang } from "../core/lang";
|
|
12
12
|
import { RowMoveManager } from "./plugins/slick.rowmovemanager";
|
|
13
|
+
import { Overlays } from "./plugins/ext.overlay";
|
|
13
14
|
var $ = jQueryReplacement;
|
|
14
15
|
export function createJSLGrid(selector, data, columns, option) {
|
|
15
16
|
var formulaObjects = [];
|
|
@@ -105,6 +106,58 @@ export function createJSLGrid(selector, data, columns, option) {
|
|
|
105
106
|
grid.render();
|
|
106
107
|
});
|
|
107
108
|
}
|
|
109
|
+
if (option.enableFillDown) {
|
|
110
|
+
var overlayPlugin = new Overlays({});
|
|
111
|
+
// Event fires when a range is selected
|
|
112
|
+
overlayPlugin.onFillUpDown.subscribe(function (e, args) {
|
|
113
|
+
var column = grid.getColumns()[args.range.fromCell];
|
|
114
|
+
// Ensure the column is editable
|
|
115
|
+
if (column.editor == null || column.readonly || !grid.getOptions().editable) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
// Find the initial value
|
|
119
|
+
dataView.beginUpdate();
|
|
120
|
+
if (args.direction === "down") {
|
|
121
|
+
var item = dataView.getItem(args.range.fromRow);
|
|
122
|
+
var value = grid.getDataItemValueForColumn(item, column); // item[column.field];
|
|
123
|
+
// Copy the value down
|
|
124
|
+
for (var i = args.range.fromRow + 1; i <= args.range.toRow; i++) {
|
|
125
|
+
if (grid.onBeforeEditCell.notify({ row: i, cell: args.range.fromCell, item: dataView.getItem(i), column: column }, e) !== false) {
|
|
126
|
+
var oldValue = grid.getDataItemValueForColumn(dataView.getItem(i), column);
|
|
127
|
+
if (options.setDataItemValueForColumn != null) {
|
|
128
|
+
options.setDataItemValueForColumn(dataView.getItem(i), column, value);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
dataView.getItem(i)[column.field] = value;
|
|
132
|
+
}
|
|
133
|
+
grid.invalidateRow(i);
|
|
134
|
+
grid.onAfterEdit.notify({ grid: grid, oldValue: oldValue, newValue: value, column: column, item: dataView.getItem(i) }, e);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
var item = dataView.getItem(args.range.toRow);
|
|
140
|
+
var value = grid.getDataItemValueForColumn(item, column); // item[column.field];
|
|
141
|
+
// Copy the value up
|
|
142
|
+
for (var i = args.range.fromRow; i <= args.range.toRow - 1; i++) {
|
|
143
|
+
if (grid.onBeforeEditCell.notify({ row: i, cell: args.range.fromCell, item: dataView.getItem(i), column: column }, e) !== false) {
|
|
144
|
+
var oldValue = grid.getDataItemValueForColumn(dataView.getItem(i), column);
|
|
145
|
+
if (options.setDataItemValueForColumn != null) {
|
|
146
|
+
options.setDataItemValueForColumn(dataView.getItem(i), column, value);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
dataView.getItem(i)[column.field] = value;
|
|
150
|
+
}
|
|
151
|
+
grid.invalidateRow(i);
|
|
152
|
+
grid.onAfterEdit.notify({ grid: grid, oldValue: oldValue, newValue: value, column: column, item: dataView.getItem(i) }, e);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
dataView.endUpdate();
|
|
157
|
+
grid.render();
|
|
158
|
+
});
|
|
159
|
+
grid.registerPlugin(overlayPlugin);
|
|
160
|
+
}
|
|
108
161
|
if (!option.explicitInitialization) {
|
|
109
162
|
grid.init();
|
|
110
163
|
}
|
|
@@ -317,10 +370,16 @@ export function createJSLGrid(selector, data, columns, option) {
|
|
|
317
370
|
}
|
|
318
371
|
// refresh formulas depending on the given column
|
|
319
372
|
function triggerFormula(column, item) {
|
|
373
|
+
var options = grid.getOptions();
|
|
320
374
|
var f = formulas[column];
|
|
321
375
|
if (f) {
|
|
322
376
|
for (var i = 0, l = f.length; i < l; i++) {
|
|
323
|
-
|
|
377
|
+
if (options.setDataItemValueForColumn != null) {
|
|
378
|
+
options.setDataItemValueForColumn(item, f[i].column, f[i].fnc(item, column));
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
item[f[i].column] = f[i].fnc(item, column);
|
|
382
|
+
}
|
|
324
383
|
}
|
|
325
384
|
}
|
|
326
385
|
}
|
|
@@ -343,7 +402,12 @@ export function createJSLGrid(selector, data, columns, option) {
|
|
|
343
402
|
item: item
|
|
344
403
|
});
|
|
345
404
|
if (afterEditResult === false) {
|
|
346
|
-
|
|
405
|
+
if (options.setDataItemValueForColumn != null) {
|
|
406
|
+
options.setDataItemValueForColumn(item, column, oldVal);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
item[column.field] = oldVal;
|
|
410
|
+
}
|
|
347
411
|
triggerFormula(column.field, item);
|
|
348
412
|
dataView.updateItem(item[options.primaryKey], item);
|
|
349
413
|
}
|
package/lib/grid/slick.grid.d.ts
CHANGED
|
@@ -249,6 +249,36 @@ export interface ISlickGrid<T> {
|
|
|
249
249
|
commitCurrentEdit: () => boolean;
|
|
250
250
|
cancelCurrentEdit: () => boolean;
|
|
251
251
|
};
|
|
252
|
+
"invalidateRow": (row: number) => void;
|
|
253
|
+
"getCanvasNode": () => HTMLElement;
|
|
254
|
+
"focus": () => void;
|
|
255
|
+
"getActiveCellPosition": () => {
|
|
256
|
+
top: number;
|
|
257
|
+
left: number;
|
|
258
|
+
bottom: number;
|
|
259
|
+
right: number;
|
|
260
|
+
width: number;
|
|
261
|
+
height: number;
|
|
262
|
+
visible: boolean;
|
|
263
|
+
};
|
|
252
264
|
"resetActiveCell": () => void;
|
|
265
|
+
"getCellNodeBox": (row: number, cell: number) => {
|
|
266
|
+
bottom: number;
|
|
267
|
+
left: number;
|
|
268
|
+
top: number;
|
|
269
|
+
right: number;
|
|
270
|
+
height: number;
|
|
271
|
+
width: number;
|
|
272
|
+
};
|
|
273
|
+
"canCellBeSelected": (row: number, cell: number) => boolean;
|
|
274
|
+
"getGridPosition": () => {
|
|
275
|
+
top: number;
|
|
276
|
+
left: number;
|
|
277
|
+
bottom: number;
|
|
278
|
+
right: number;
|
|
279
|
+
width: number;
|
|
280
|
+
height: number;
|
|
281
|
+
visible: boolean;
|
|
282
|
+
};
|
|
253
283
|
}
|
|
254
284
|
export declare function SlickGrid(container: HTMLDivElement | string, data: any, columns: ISlickColumn[], options: ISlickGridOptions): void;
|
package/lib/index.css
CHANGED
|
@@ -641,6 +641,35 @@ input.editor-text, textarea.editor-text {
|
|
|
641
641
|
background-repeat: no-repeat;
|
|
642
642
|
}
|
|
643
643
|
|
|
644
|
+
.header-overlay {
|
|
645
|
+
background-color: #217346;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
.cell-overlay, .selection-cell-overlay {
|
|
649
|
+
z-index: 900;
|
|
650
|
+
background-color: #217346;
|
|
651
|
+
display: block;
|
|
652
|
+
position: absolute;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.handle-overlay {
|
|
656
|
+
width: 2px;
|
|
657
|
+
height: 2px;
|
|
658
|
+
z-index: 1000;
|
|
659
|
+
cursor: crosshair;
|
|
660
|
+
background-color: #217346;
|
|
661
|
+
border: 1px solid #fff;
|
|
662
|
+
padding: 3px;
|
|
663
|
+
position: absolute;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
.overlay-handle-decorator {
|
|
667
|
+
z-index: 1000;
|
|
668
|
+
border: 2px solid #217346;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
|
|
644
673
|
.slick-cell .jsl-toggle {
|
|
645
674
|
color: #888;
|
|
646
675
|
width: 1.2em;
|