jsxgrid 2.3.0 → 2.4.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/README.md +48 -0
- package/dist/fields/jsgrid.field.XDateTimeField.min.js +2 -2
- package/dist/fields/jsgrid.field.XRowSelectField.min.js +1 -1
- package/dist/fields/jsgrid.field.Xcheckbox.min.js +2 -2
- package/dist/fields/jsgrid.field.Xcontrol.min.js +1 -1
- package/dist/fields/jsgrid.field.XimgField.min.js +2 -2
- package/dist/fields/jsgrid.field.Xjsoneditor.min.js +2 -2
- package/dist/fields/jsgrid.field.Xnumber.min.js +2 -2
- package/dist/fields/jsgrid.field.Xselect.min.js +2 -2
- package/dist/fields/jsgrid.field.Xtext.min.js +2 -2
- package/dist/fields/jsgrid.field.Xtextarea.min.js +2 -2
- package/dist/fields/lib/jsGridSummaryPlugin.min.js +1 -1
- package/dist/fields/lib/jsgrid.popup.basic.min.js +1 -1
- package/dist/jsxgrid-fields.js +1 -1
- package/dist/jsxgrid-fields.min.js +1 -1
- package/dist/jsxgrid-theme.css +1 -1
- package/dist/jsxgrid-xfields.js +91 -58
- package/dist/jsxgrid-xfields.min.js +2 -2
- package/dist/jsxgrid.css +1 -1
- package/dist/jsxgrid.js +56 -14
- package/dist/jsxgrid.min.js +2 -2
- package/package.json +1 -1
- package/src/fields/jsgrid.field.XDateTimeField.js +10 -9
- package/src/fields/jsgrid.field.Xcheckbox.js +14 -9
- package/src/fields/jsgrid.field.XimgField.js +10 -9
- package/src/fields/jsgrid.field.Xjsoneditor.js +15 -9
- package/src/fields/jsgrid.field.Xnumber.js +6 -1
- package/src/fields/jsgrid.field.Xselect.js +15 -10
- package/src/fields/jsgrid.field.Xtext.js +6 -1
- package/src/fields/jsgrid.field.Xtextarea.js +14 -9
- package/src/jsgrid.core.js +54 -12
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
(function(jsGrid, $, undefined) {
|
|
2
|
-
|
|
3
|
-
if (!jsGrid) {
|
|
4
|
-
if (window.console) {
|
|
5
|
-
console.error("[jsxgrid] jsgrid.field.Xselect.js was loaded before the jsxgrid engine (jsxgrid.js) - include the engine first.");
|
|
6
|
-
}
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
1
|
+
(function(jsGrid, $, undefined) {
|
|
2
|
+
|
|
3
|
+
if (!jsGrid) {
|
|
4
|
+
if (window.console) {
|
|
5
|
+
console.error("[jsxgrid] jsgrid.field.Xselect.js was loaded before the jsxgrid engine (jsxgrid.js) - include the engine first.");
|
|
6
|
+
}
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
// Standalone: does not extend jsGrid.SelectField, only jsGrid.Field.
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
valueType: NUMBER_VALUE_TYPE,
|
|
36
36
|
pseudoElement: null,//pseudoElement that will be unsifted to start of select data in filters
|
|
37
37
|
select2: null,
|
|
38
|
-
defaultSelected: null,
|
|
38
|
+
defaultSelected: null,//value to preselect in the filter, applied once on first filter render then reset
|
|
39
|
+
defaultValue: null,//value to preselect in the insert row, applied every time a fresh insert row is built (not reset after use, unlike defaultSelected)
|
|
39
40
|
|
|
40
41
|
itemTemplate: function (value) {
|
|
41
42
|
var items = this.items,
|
|
@@ -64,7 +65,11 @@
|
|
|
64
65
|
if (!this.inserting)
|
|
65
66
|
return "";
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
var $result = this.insertControl = this._createSelect();
|
|
69
|
+
if (this.defaultValue !== null) {
|
|
70
|
+
$result.val(this.defaultValue);
|
|
71
|
+
}
|
|
72
|
+
return $result;
|
|
68
73
|
},
|
|
69
74
|
|
|
70
75
|
editTemplate: function (value) {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
autosearch: true,
|
|
21
21
|
readOnly: false,
|
|
22
22
|
defaultSelected: null,//value to preset the filter input with, applied once on first filter render then reset
|
|
23
|
+
defaultValue: null,//value to prefill the insert row with, applied every time a fresh insert row is built (not reset after use, unlike defaultSelected)
|
|
23
24
|
|
|
24
25
|
filterTemplate: function () {
|
|
25
26
|
if (!this.filtering)
|
|
@@ -49,7 +50,11 @@
|
|
|
49
50
|
if (!this.inserting)
|
|
50
51
|
return "";
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
var $result = this.insertControl = this._createTextBox();
|
|
54
|
+
if (this.defaultValue !== null) {
|
|
55
|
+
$result.val(this.defaultValue);
|
|
56
|
+
}
|
|
57
|
+
return $result;
|
|
53
58
|
},
|
|
54
59
|
|
|
55
60
|
editTemplate: function (value) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
(function(jsGrid, $, undefined) {
|
|
2
|
-
|
|
3
|
-
if (!jsGrid) {
|
|
4
|
-
if (window.console) {
|
|
5
|
-
console.error("[jsxgrid] jsgrid.field.Xtextarea.js was loaded before the jsxgrid engine (jsxgrid.js) - include the engine first.");
|
|
6
|
-
}
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
1
|
+
(function(jsGrid, $, undefined) {
|
|
2
|
+
|
|
3
|
+
if (!jsGrid) {
|
|
4
|
+
if (window.console) {
|
|
5
|
+
console.error("[jsxgrid] jsgrid.field.Xtextarea.js was loaded before the jsxgrid engine (jsxgrid.js) - include the engine first.");
|
|
6
|
+
}
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
// Standalone: does not extend jsGrid.TextAreaField, only jsGrid.Field.
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
readOnly: false,
|
|
22
22
|
maxShowSymbols: 50,
|
|
23
23
|
defaultSelected: null,//value to preset the filter input with, applied once on first filter render then reset
|
|
24
|
+
defaultValue: null,//value to prefill the insert row with, applied every time a fresh insert row is built (not reset after use, unlike defaultSelected)
|
|
24
25
|
|
|
25
26
|
filterTemplate: function () {
|
|
26
27
|
if (!this.filtering)
|
|
@@ -54,7 +55,11 @@
|
|
|
54
55
|
if (!this.inserting)
|
|
55
56
|
return "";
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
var $result = this.insertControl = this._createTextArea();
|
|
59
|
+
if (this.defaultValue !== null) {
|
|
60
|
+
$result.val(this.defaultValue);
|
|
61
|
+
}
|
|
62
|
+
return $result;
|
|
58
63
|
},
|
|
59
64
|
|
|
60
65
|
editTemplate: function (value) {
|
package/src/jsgrid.core.js
CHANGED
|
@@ -136,6 +136,13 @@
|
|
|
136
136
|
sortAscClass: "jsgrid-header-sort jsgrid-header-sort-asc",
|
|
137
137
|
sortDescClass: "jsgrid-header-sort jsgrid-header-sort-desc",
|
|
138
138
|
|
|
139
|
+
// jsxgrid extension: initial sort applied once at construction (field
|
|
140
|
+
// name/index/reference + "asc"/"desc"), baked into the first render/load
|
|
141
|
+
// instead of requiring a separate sort() call (and the extra
|
|
142
|
+
// refresh/reload that would trigger) right after creating the grid.
|
|
143
|
+
sortField: null,
|
|
144
|
+
sortOrder: null,
|
|
145
|
+
|
|
139
146
|
paging: false,
|
|
140
147
|
pagerContainer: null,
|
|
141
148
|
pageIndex: 1,
|
|
@@ -209,11 +216,38 @@
|
|
|
209
216
|
this._initLoadStrategy();
|
|
210
217
|
this._initController();
|
|
211
218
|
this._initFields();
|
|
219
|
+
this._initSorting();
|
|
212
220
|
this._attachWindowLoadResize();
|
|
213
221
|
this._attachWindowResizeCallback();
|
|
214
222
|
this._callEventHandler(this.onInit)
|
|
215
223
|
},
|
|
216
224
|
|
|
225
|
+
_initSorting: function() {
|
|
226
|
+
if(!this.sortField) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
var field = this._normalizeField(this.sortField);
|
|
231
|
+
if(!field) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
this._sortField = field;
|
|
236
|
+
this._sortOrder = this.sortOrder || SORT_ORDER_ASC;
|
|
237
|
+
|
|
238
|
+
// Static in-memory data (already present at construction time, not
|
|
239
|
+
// fetched via a controller) needs an explicit sort here - normal
|
|
240
|
+
// rendering never sorts on its own, only an actual sort() call does
|
|
241
|
+
// (see DirectLoadingStrategy.sort()). Controller-backed data follows
|
|
242
|
+
// the same rule sorting already does elsewhere: pageLoading sends
|
|
243
|
+
// sortField/sortOrder to the server via loadData()'s filter, while
|
|
244
|
+
// plain (non-paged) controller data is left as the controller
|
|
245
|
+
// returns it, same as clicking a sortable header would leave it.
|
|
246
|
+
if($.isArray(this.data) && this.data.length) {
|
|
247
|
+
this._sortData();
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
|
|
217
251
|
_initInstanceLocale: function(locale) {
|
|
218
252
|
if(!locale) {
|
|
219
253
|
return;
|
|
@@ -533,6 +567,10 @@
|
|
|
533
567
|
.on("click", $.proxy(function() {
|
|
534
568
|
this.sort(index);
|
|
535
569
|
}, this));
|
|
570
|
+
|
|
571
|
+
if(field === this._sortField) {
|
|
572
|
+
$th.addClass(this._sortOrder === SORT_ORDER_ASC ? this.sortAscClass : this.sortDescClass);
|
|
573
|
+
}
|
|
536
574
|
}
|
|
537
575
|
});
|
|
538
576
|
|
|
@@ -591,7 +629,6 @@
|
|
|
591
629
|
},
|
|
592
630
|
|
|
593
631
|
_resetPager: function() {
|
|
594
|
-
this._firstDisplayingPage = 1;
|
|
595
632
|
this._setPage(1);
|
|
596
633
|
},
|
|
597
634
|
|
|
@@ -1059,24 +1096,29 @@
|
|
|
1059
1096
|
},
|
|
1060
1097
|
|
|
1061
1098
|
_setPage: function(pageIndex) {
|
|
1062
|
-
var firstDisplayingPage = this._firstDisplayingPage,
|
|
1063
|
-
pageButtonCount = this.pageButtonCount;
|
|
1064
|
-
|
|
1065
1099
|
this.pageIndex = pageIndex;
|
|
1066
|
-
|
|
1067
|
-
if(pageIndex < firstDisplayingPage) {
|
|
1068
|
-
this._firstDisplayingPage = pageIndex;
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
if(pageIndex > firstDisplayingPage + pageButtonCount - 1) {
|
|
1072
|
-
this._firstDisplayingPage = pageIndex - pageButtonCount + 1;
|
|
1073
|
-
}
|
|
1100
|
+
this._firstDisplayingPage = this._centeredFirstDisplayingPage(pageIndex);
|
|
1074
1101
|
|
|
1075
1102
|
this._callEventHandler(this.onPageChanged, {
|
|
1076
1103
|
pageIndex: pageIndex
|
|
1077
1104
|
});
|
|
1078
1105
|
},
|
|
1079
1106
|
|
|
1107
|
+
// Keeps the visible page-number window centered on pageIndex (e.g.
|
|
1108
|
+
// pageButtonCount=5 shows pageIndex-2 .. pageIndex+2), clamped to the
|
|
1109
|
+
// actual page range, instead of only shifting once pageIndex falls
|
|
1110
|
+
// outside the previous window - so the next/prev page is always just
|
|
1111
|
+
// one click away, without ever needing the "..." nav button first.
|
|
1112
|
+
_centeredFirstDisplayingPage: function(pageIndex) {
|
|
1113
|
+
var pageButtonCount = this.pageButtonCount,
|
|
1114
|
+
pageCount = this._pagesCount(),
|
|
1115
|
+
halfWindow = Math.floor((pageButtonCount - 1) / 2),
|
|
1116
|
+
first = pageIndex - halfWindow,
|
|
1117
|
+
lastPossibleFirst = Math.max(1, pageCount - pageButtonCount + 1);
|
|
1118
|
+
|
|
1119
|
+
return Math.min(Math.max(1, first), lastPossibleFirst);
|
|
1120
|
+
},
|
|
1121
|
+
|
|
1080
1122
|
_controllerCall: function(method, param, isCanceled, doneCallback) {
|
|
1081
1123
|
if(isCanceled)
|
|
1082
1124
|
return $.Deferred().reject().promise();
|