jsl-ui 9.11.0 → 9.13.0
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/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 +276 -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 +36 -1
- package/lib/grid/slick.grid.js +12 -4
- 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
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,276 @@
|
|
|
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
|
+
console.log("onstart");
|
|
198
|
+
handleOverlayDragStart(e);
|
|
199
|
+
}),
|
|
200
|
+
onMove: EventHandler.Create(function (e) {
|
|
201
|
+
console.log("onMove");
|
|
202
|
+
handleOverlayDrag(e);
|
|
203
|
+
}),
|
|
204
|
+
onStop: EventHandler.Create(function (e) {
|
|
205
|
+
console.log("onStop");
|
|
206
|
+
handleOverlayDragEnd(e);
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
this.toggle = function (showOrHide) {
|
|
211
|
+
this.$left.css("display", showOrHide ? "" : "none");
|
|
212
|
+
this.$right.css("display", showOrHide ? "" : "none");
|
|
213
|
+
this.$top.css("display", showOrHide ? "" : "none");
|
|
214
|
+
this.$bottom.css("display", showOrHide ? "" : "none");
|
|
215
|
+
if (this.handle) {
|
|
216
|
+
this.handle.style.display = showOrHide ? "" : "none";
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function overlayRangeDecorator(targetGrid) {
|
|
221
|
+
var decorator;
|
|
222
|
+
var r;
|
|
223
|
+
function show(range) {
|
|
224
|
+
r = range;
|
|
225
|
+
if (!decorator) {
|
|
226
|
+
decorator = new Overlay(grid.getCanvasNode(), false, 'selection-');
|
|
227
|
+
}
|
|
228
|
+
var from = targetGrid.getCellNodeBox(range.fromRow, range.fromCell);
|
|
229
|
+
var to = targetGrid.getCellNodeBox(range.toRow, range.toCell);
|
|
230
|
+
decorator.$left.css({
|
|
231
|
+
top: from.top - 2,
|
|
232
|
+
left: from.left - 2,
|
|
233
|
+
height: to.bottom - from.top + 2,
|
|
234
|
+
width: options.decoratorWidth
|
|
235
|
+
});
|
|
236
|
+
decorator.$right.css({
|
|
237
|
+
top: from.top - 2,
|
|
238
|
+
left: to.right - 1,
|
|
239
|
+
height: to.bottom - from.top + 2,
|
|
240
|
+
width: options.decoratorWidth
|
|
241
|
+
});
|
|
242
|
+
decorator.$top.css({
|
|
243
|
+
top: from.top - 2,
|
|
244
|
+
left: to.left - 1,
|
|
245
|
+
height: options.decoratorWidth,
|
|
246
|
+
width: to.right - from.left + 2
|
|
247
|
+
});
|
|
248
|
+
decorator.$bottom.css({
|
|
249
|
+
top: to.bottom - 1,
|
|
250
|
+
left: from.left - 2,
|
|
251
|
+
height: options.decoratorWidth,
|
|
252
|
+
width: to.right - from.left + 3
|
|
253
|
+
});
|
|
254
|
+
return decorator;
|
|
255
|
+
}
|
|
256
|
+
function getSelectedRange() {
|
|
257
|
+
return r;
|
|
258
|
+
}
|
|
259
|
+
function hide() {
|
|
260
|
+
if (decorator) {
|
|
261
|
+
decorator.toggle(false);
|
|
262
|
+
decorator = null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
hide: hide,
|
|
267
|
+
show: show,
|
|
268
|
+
getSelectedRange: getSelectedRange
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
$.shallowExtend(this, {
|
|
272
|
+
"init": init,
|
|
273
|
+
"destroy": destroy,
|
|
274
|
+
"onFillUpDown": new Slick.Event()
|
|
275
|
+
});
|
|
276
|
+
}
|
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
|
@@ -114,7 +114,12 @@ export interface ISlickGrid<T> {
|
|
|
114
114
|
row: number;
|
|
115
115
|
cell: number;
|
|
116
116
|
}>;
|
|
117
|
-
"onColumnsResized": ISlickEvent<
|
|
117
|
+
"onColumnsResized": ISlickEvent<{
|
|
118
|
+
cell: number;
|
|
119
|
+
width: number;
|
|
120
|
+
previousWidth: number;
|
|
121
|
+
column: ISlickColumn;
|
|
122
|
+
}[]>;
|
|
118
123
|
"onAppendCell": ISlickEvent<{
|
|
119
124
|
row: number;
|
|
120
125
|
cell: number;
|
|
@@ -244,6 +249,36 @@ export interface ISlickGrid<T> {
|
|
|
244
249
|
commitCurrentEdit: () => boolean;
|
|
245
250
|
cancelCurrentEdit: () => boolean;
|
|
246
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
|
+
};
|
|
247
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
|
+
};
|
|
248
283
|
}
|
|
249
284
|
export declare function SlickGrid(container: HTMLDivElement | string, data: any, columns: ISlickColumn[], options: ISlickGridOptions): void;
|
package/lib/grid/slick.grid.js
CHANGED
|
@@ -1795,21 +1795,29 @@ export function SlickGrid(container, data, columns, options) {
|
|
|
1795
1795
|
}
|
|
1796
1796
|
}
|
|
1797
1797
|
function finishColumnResize() {
|
|
1798
|
+
var changedColumns = [];
|
|
1798
1799
|
var newWidth;
|
|
1799
1800
|
var columnElements = $headers.children();
|
|
1800
1801
|
$headers.find(".slick-header-column-active").removeClass("slick-header-column-active");
|
|
1801
1802
|
for (var j = 0; j < columns.length; j++) {
|
|
1802
1803
|
var c = columns[j];
|
|
1803
1804
|
newWidth = $(columnElements[j]).width();
|
|
1804
|
-
if (c.previousWidth !== newWidth
|
|
1805
|
-
|
|
1806
|
-
|
|
1805
|
+
if (c.previousWidth !== newWidth) {
|
|
1806
|
+
changedColumns.push({ cell: j,
|
|
1807
|
+
width: newWidth,
|
|
1808
|
+
previousWidth: c.previousWidth,
|
|
1809
|
+
column: c
|
|
1810
|
+
});
|
|
1811
|
+
if (c.rerenderOnResize) {
|
|
1812
|
+
invalidateAllRows();
|
|
1813
|
+
break;
|
|
1814
|
+
}
|
|
1807
1815
|
}
|
|
1808
1816
|
}
|
|
1809
1817
|
updateCanvasWidth(true);
|
|
1810
1818
|
resizeCanvas();
|
|
1811
1819
|
handleScroll();
|
|
1812
|
-
trigger(self.onColumnsResized,
|
|
1820
|
+
trigger(self.onColumnsResized, changedColumns);
|
|
1813
1821
|
}
|
|
1814
1822
|
// function setupColumnResize() {
|
|
1815
1823
|
// if (1) return;
|
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;
|