jsxgrid 2.0.0 → 2.1.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 +29 -0
- package/dist/fields/jsgrid.field.XDateTimeField.min.js +1 -1
- package/dist/fields/jsgrid.field.XRowSelectField.min.js +1 -1
- package/dist/fields/jsgrid.field.Xcheckbox.min.js +1 -1
- package/dist/fields/jsgrid.field.Xcontrol.min.js +6 -0
- package/dist/fields/jsgrid.field.XimgField.min.js +1 -1
- package/dist/fields/jsgrid.field.Xjsoneditor.min.js +1 -1
- package/dist/fields/jsgrid.field.Xnumber.min.js +6 -0
- package/dist/fields/jsgrid.field.Xselect.min.js +1 -1
- package/dist/fields/jsgrid.field.Xtext.min.js +6 -0
- package/dist/fields/jsgrid.field.Xtextarea.min.js +1 -1
- 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 +393 -2
- package/dist/jsxgrid-xfields.min.js +2 -2
- package/dist/jsxgrid.css +1 -1
- package/dist/jsxgrid.js +2 -2
- package/dist/jsxgrid.min.js +2 -2
- package/package.json +1 -1
- package/src/fields/jsgrid.field.Xcontrol.js +229 -0
- package/src/fields/jsgrid.field.Xnumber.js +84 -0
- package/src/fields/jsgrid.field.Xtext.js +76 -0
package/README.md
CHANGED
|
@@ -680,6 +680,29 @@ never filters) supports a shared `defaultSelected` convention: a value used to p
|
|
|
680
680
|
*first* time its filter row is rendered, then reset to `null` so it doesn't keep overriding what the user
|
|
681
681
|
searches for afterwards.
|
|
682
682
|
|
|
683
|
+
As of `Xtext`/`Xnumber`/`Xcontrol`, every native field type (`text`, `number`, `select`, `checkbox`,
|
|
684
|
+
`textarea`, `control`) now has an X-branded equivalent — the native set (`dist/jsxgrid-fields.js`) is kept
|
|
685
|
+
around as legacy/optional, with new work going into the X set going forward.
|
|
686
|
+
|
|
687
|
+
#### Xtext
|
|
688
|
+
|
|
689
|
+
Drop-in replacement for `text`.
|
|
690
|
+
|
|
691
|
+
| Option | Default | Description |
|
|
692
|
+
|---|---|---|
|
|
693
|
+
| `readOnly` | `false` | Whether the input is readonly. |
|
|
694
|
+
| `defaultSelected` | `null` | A string to preset the filter input with. |
|
|
695
|
+
|
|
696
|
+
#### Xnumber
|
|
697
|
+
|
|
698
|
+
Drop-in replacement for `number`. Standalone — does not extend `Xtext`, only `jsGrid.Field` directly, same as
|
|
699
|
+
every other X-field.
|
|
700
|
+
|
|
701
|
+
| Option | Default | Description |
|
|
702
|
+
|---|---|---|
|
|
703
|
+
| `readOnly` | `false` | Whether the input is readonly. |
|
|
704
|
+
| `defaultSelected` | `null` | A number (or numeric string) to preset the filter input with. |
|
|
705
|
+
|
|
683
706
|
#### Xcheckbox
|
|
684
707
|
|
|
685
708
|
Drop-in replacement for `checkbox`. Returns `1`/`0` instead of `true`/`false`, which avoids a lot of backend
|
|
@@ -756,6 +779,12 @@ Date/datetime field backed by a native `<input type="datetime-local">` (or whate
|
|
|
756
779
|
| `options` | built-in `Intl.DateTimeFormat` options | Passed to `toLocaleDateString()` when rendering the item view. Empty values render as an empty string. |
|
|
757
780
|
| `defaultSelected` | `null` | A value (matching `datePickerType`'s input format) to preset the filter with. When `dateRange` is `true`, pass `{from, to}` instead. |
|
|
758
781
|
|
|
782
|
+
#### Xcontrol
|
|
783
|
+
|
|
784
|
+
Drop-in replacement for `control`. Already standalone even as a native field (extends `jsGrid.Field`
|
|
785
|
+
directly), so this is a straight rename — no behavior changes, no `defaultSelected` (nothing to filter by).
|
|
786
|
+
Same custom properties as [`control`](#control).
|
|
787
|
+
|
|
759
788
|
#### popup.basic
|
|
760
789
|
|
|
761
790
|
A minimal, jQuery-only modal used by `Xjsoneditor` (and available for your own use) as `jsGrid.popup` /
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* jsxgrid v2.1.0 (https://github.com/rok9ru/jsxgrid#readme)
|
|
3
|
+
* (c) 2026 Mikhail Kremza
|
|
4
|
+
* Licensed under MIT
|
|
5
|
+
*/
|
|
6
|
+
((t,r)=>{var e=t.Field;function i(t){e.call(this,t),this.includeInDataExport=!1,this._configInitialized=!1}i.prototype=new e({css:"jsgrid-control-field",align:"center",width:50,filtering:!1,inserting:!1,editing:!1,sorting:!1,buttonClass:"jsgrid-button",modeButtonClass:"jsgrid-mode-button",modeOnButtonClass:"jsgrid-mode-on-button",searchModeButtonClass:"jsgrid-search-mode-button",insertModeButtonClass:"jsgrid-insert-mode-button",editButtonClass:"jsgrid-edit-button",deleteButtonClass:"jsgrid-delete-button",searchButtonClass:"jsgrid-search-button",clearFilterButtonClass:"jsgrid-clear-filter-button",insertButtonClass:"jsgrid-insert-button",updateButtonClass:"jsgrid-update-button",cancelEditButtonClass:"jsgrid-cancel-edit-button",searchModeButtonTooltip:"Switch to searching",insertModeButtonTooltip:"Switch to inserting",editButtonTooltip:"Edit",deleteButtonTooltip:"Delete",searchButtonTooltip:"Search",clearFilterButtonTooltip:"Clear filter",insertButtonTooltip:"Insert",updateButtonTooltip:"Update",cancelEditButtonTooltip:"Cancel edit",editButton:!0,deleteButton:!0,clearFilterButton:!0,modeSwitchButton:!0,_initConfig:function(){this._hasFiltering=this._grid.filtering,this._hasInserting=this._grid.inserting,this._hasInserting&&this.modeSwitchButton&&(this._grid.inserting=!1),this._configInitialized=!0},headerTemplate:function(){this._configInitialized||this._initConfig();var t=this._hasFiltering,e=this._hasInserting;return this.modeSwitchButton&&(t||e)?t&&!e?this._createFilterSwitchButton():e&&!t?this._createInsertSwitchButton():this._createModeSwitchButton():""},itemTemplate:function(t,e){var i=r([]);return this.editButton&&(i=i.add(this._createEditButton(e))),i=this.deleteButton?i.add(this._createDeleteButton(e)):i},filterTemplate:function(){var t=this._createSearchButton();return this.clearFilterButton?t.add(this._createClearFilterButton()):t},insertTemplate:function(){return this._createInsertButton()},editTemplate:function(){return this._createUpdateButton().add(this._createCancelEditButton())},_createFilterSwitchButton:function(){return this._createOnOffSwitchButton("filtering",this.searchModeButtonClass,!0)},_createInsertSwitchButton:function(){return this._createOnOffSwitchButton("inserting",this.insertModeButtonClass,!1)},_createOnOffSwitchButton:function(e,t,i){var n=i,o=r.proxy(function(){s.toggleClass(this.modeOnButtonClass,n)},this),s=this._createGridButton(this.modeButtonClass+" "+t,"",function(t){n=!n,t.option(e,n),o()});return o(),s},_createModeSwitchButton:function(){var e=!1,i=r.proxy(function(){t.attr("title",e?this.searchModeButtonTooltip:this.insertModeButtonTooltip).toggleClass(this.insertModeButtonClass,!e).toggleClass(this.searchModeButtonClass,e)},this),t=this._createGridButton(this.modeButtonClass,"",function(t){e=!e,t.option("inserting",e),t.option("filtering",!e),i()});return i(),t},_createEditButton:function(i){return this._createGridButton(this.editButtonClass,this.editButtonTooltip,function(t,e){t.editItem(i),e.stopPropagation()})},_createDeleteButton:function(i){return this._createGridButton(this.deleteButtonClass,this.deleteButtonTooltip,function(t,e){t.deleteItem(i),e.stopPropagation()})},_createSearchButton:function(){return this._createGridButton(this.searchButtonClass,this.searchButtonTooltip,function(t){t.search()})},_createClearFilterButton:function(){return this._createGridButton(this.clearFilterButtonClass,this.clearFilterButtonTooltip,function(t){t.clearFilter()})},_createInsertButton:function(){return this._createGridButton(this.insertButtonClass,this.insertButtonTooltip,function(t){t.insertItem().done(function(){t.clearInsert()})})},_createUpdateButton:function(){return this._createGridButton(this.updateButtonClass,this.updateButtonTooltip,function(t,e){t.updateItem(),e.stopPropagation()})},_createCancelEditButton:function(){return this._createGridButton(this.cancelEditButtonClass,this.cancelEditButtonTooltip,function(t,e){t.cancelEdit(),e.stopPropagation()})},_createGridButton:function(t,e,i){var n=this._grid;return r("<input>").addClass(this.buttonClass).addClass(t).attr({type:"button",title:e}).on("click",function(t){i(n,t)})},editValue:function(){return""}}),t.fields.Xcontrol=i})(jsGrid,jQuery);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* jsxgrid v2.1.0 (https://github.com/rok9ru/jsxgrid#readme)
|
|
3
|
+
* (c) 2026 Mikhail Kremza
|
|
4
|
+
* Licensed under MIT
|
|
5
|
+
*/
|
|
6
|
+
((t,e,r)=>{function i(t){n.call(this,t)}var n=t.Field;i.prototype=new n({sorter:"number",align:"right",autosearch:!0,readOnly:!1,defaultSelected:null,filterTemplate:function(){var e,t;return this.filtering?(e=this._grid,t=this.filterControl=this._createTextBox(),this.autosearch&&t.on("keypress",function(t){13===t.which&&(e.search(),t.preventDefault())}),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),t):""},insertTemplate:function(){return this.inserting?this.insertControl=this._createTextBox():""},editTemplate:function(t){var e;return this.editing?((e=this.editControl=this._createTextBox()).val(t),e):this.itemTemplate.apply(this,arguments)},filterValue:function(){return this.filterControl.val()?parseInt(this.filterControl.val()||0,10):r},insertValue:function(){return this.insertControl.val()?parseInt(this.insertControl.val()||0,10):r},editValue:function(){return this.editControl.val()?parseInt(this.editControl.val()||0,10):r},_createTextBox:function(){return e("<input>").attr("type","number").prop("readonly",!!this.readOnly)}}),t.fields.Xnumber=i})(jsGrid,jQuery);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* jsxgrid v2.1.0 (https://github.com/rok9ru/jsxgrid#readme)
|
|
3
|
+
* (c) 2026 Mikhail Kremza
|
|
4
|
+
* Licensed under MIT
|
|
5
|
+
*/
|
|
6
|
+
((t,e)=>{function i(t){r.call(this,t)}var r=t.Field;i.prototype=new r({autosearch:!0,readOnly:!1,defaultSelected:null,filterTemplate:function(){var e,t;return this.filtering?(e=this._grid,t=this.filterControl=this._createTextBox(),this.autosearch&&t.on("keypress",function(t){13===t.which&&(e.search(),t.preventDefault())}),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),t):""},insertTemplate:function(){return this.inserting?this.insertControl=this._createTextBox():""},editTemplate:function(t){var e;return this.editing?((e=this.editControl=this._createTextBox()).val(t),e):this.itemTemplate.apply(this,arguments)},filterValue:function(){return this.filterControl.val()},insertValue:function(){return this.insertControl.val()},editValue:function(){return this.editControl.val()},_createTextBox:function(){return e("<input>").attr("type","text").prop("readonly",!!this.readOnly)}}),t.fields.Xtext=i})(jsGrid,jQuery);
|
package/dist/jsxgrid-fields.js
CHANGED
package/dist/jsxgrid-theme.css
CHANGED
package/dist/jsxgrid-xfields.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* jsxgrid v2.
|
|
2
|
+
* jsxgrid v2.1.0 (https://github.com/rok9ru/jsxgrid#readme)
|
|
3
3
|
* (c) 2026 Mikhail Kremza
|
|
4
4
|
* Licensed under MIT
|
|
5
5
|
*/
|
|
@@ -148,6 +148,168 @@
|
|
|
148
148
|
return baseJsGrid.apply(this, arguments);
|
|
149
149
|
};
|
|
150
150
|
}(jQuery));
|
|
151
|
+
(function(jsGrid, $, undefined) {
|
|
152
|
+
|
|
153
|
+
// Standalone: does not extend jsGrid.TextField, only jsGrid.Field.
|
|
154
|
+
|
|
155
|
+
var Field = jsGrid.Field;
|
|
156
|
+
|
|
157
|
+
var Xtext = function (config) {
|
|
158
|
+
Field.call(this, config);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
Xtext.prototype = new Field({
|
|
162
|
+
autosearch: true,
|
|
163
|
+
readOnly: false,
|
|
164
|
+
defaultSelected: null,//value to preset the filter input with, applied once on first filter render then reset
|
|
165
|
+
|
|
166
|
+
filterTemplate: function () {
|
|
167
|
+
if (!this.filtering)
|
|
168
|
+
return "";
|
|
169
|
+
|
|
170
|
+
var grid = this._grid,
|
|
171
|
+
$result = this.filterControl = this._createTextBox();
|
|
172
|
+
|
|
173
|
+
if (this.autosearch) {
|
|
174
|
+
$result.on("keypress", function (e) {
|
|
175
|
+
if (e.which === 13) {
|
|
176
|
+
grid.search();
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (this.defaultSelected !== null) {
|
|
183
|
+
$result.val(this.defaultSelected);
|
|
184
|
+
this.defaultSelected = null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return $result;
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
insertTemplate: function () {
|
|
191
|
+
if (!this.inserting)
|
|
192
|
+
return "";
|
|
193
|
+
|
|
194
|
+
return this.insertControl = this._createTextBox();
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
editTemplate: function (value) {
|
|
198
|
+
if (!this.editing)
|
|
199
|
+
return this.itemTemplate.apply(this, arguments);
|
|
200
|
+
|
|
201
|
+
var $result = this.editControl = this._createTextBox();
|
|
202
|
+
$result.val(value);
|
|
203
|
+
return $result;
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
filterValue: function () {
|
|
207
|
+
return this.filterControl.val();
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
insertValue: function () {
|
|
211
|
+
return this.insertControl.val();
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
editValue: function () {
|
|
215
|
+
return this.editControl.val();
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
_createTextBox: function () {
|
|
219
|
+
return $("<input>").attr("type", "text")
|
|
220
|
+
.prop("readonly", !!this.readOnly);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
jsGrid.fields.Xtext = Xtext;
|
|
225
|
+
|
|
226
|
+
}(jsGrid, jQuery));
|
|
227
|
+
|
|
228
|
+
(function(jsGrid, $, undefined) {
|
|
229
|
+
|
|
230
|
+
// Standalone: does not extend jsGrid.NumberField or Xtext, only jsGrid.Field.
|
|
231
|
+
|
|
232
|
+
var Field = jsGrid.Field;
|
|
233
|
+
|
|
234
|
+
var Xnumber = function (config) {
|
|
235
|
+
Field.call(this, config);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
Xnumber.prototype = new Field({
|
|
239
|
+
sorter: "number",
|
|
240
|
+
align: "right",
|
|
241
|
+
autosearch: true,
|
|
242
|
+
readOnly: false,
|
|
243
|
+
defaultSelected: null,//value to preset the filter input with, applied once on first filter render then reset
|
|
244
|
+
|
|
245
|
+
filterTemplate: function () {
|
|
246
|
+
if (!this.filtering)
|
|
247
|
+
return "";
|
|
248
|
+
|
|
249
|
+
var grid = this._grid,
|
|
250
|
+
$result = this.filterControl = this._createTextBox();
|
|
251
|
+
|
|
252
|
+
if (this.autosearch) {
|
|
253
|
+
$result.on("keypress", function (e) {
|
|
254
|
+
if (e.which === 13) {
|
|
255
|
+
grid.search();
|
|
256
|
+
e.preventDefault();
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (this.defaultSelected !== null) {
|
|
262
|
+
$result.val(this.defaultSelected);
|
|
263
|
+
this.defaultSelected = null;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return $result;
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
insertTemplate: function () {
|
|
270
|
+
if (!this.inserting)
|
|
271
|
+
return "";
|
|
272
|
+
|
|
273
|
+
return this.insertControl = this._createTextBox();
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
editTemplate: function (value) {
|
|
277
|
+
if (!this.editing)
|
|
278
|
+
return this.itemTemplate.apply(this, arguments);
|
|
279
|
+
|
|
280
|
+
var $result = this.editControl = this._createTextBox();
|
|
281
|
+
$result.val(value);
|
|
282
|
+
return $result;
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
filterValue: function () {
|
|
286
|
+
return this.filterControl.val()
|
|
287
|
+
? parseInt(this.filterControl.val() || 0, 10)
|
|
288
|
+
: undefined;
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
insertValue: function () {
|
|
292
|
+
return this.insertControl.val()
|
|
293
|
+
? parseInt(this.insertControl.val() || 0, 10)
|
|
294
|
+
: undefined;
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
editValue: function () {
|
|
298
|
+
return this.editControl.val()
|
|
299
|
+
? parseInt(this.editControl.val() || 0, 10)
|
|
300
|
+
: undefined;
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
_createTextBox: function () {
|
|
304
|
+
return $("<input>").attr("type", "number")
|
|
305
|
+
.prop("readonly", !!this.readOnly);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
jsGrid.fields.Xnumber = Xnumber;
|
|
310
|
+
|
|
311
|
+
}(jsGrid, jQuery));
|
|
312
|
+
|
|
151
313
|
(function(jsGrid, $, undefined) {
|
|
152
314
|
|
|
153
315
|
// Standalone: does not extend jsGrid.CheckboxField, only jsGrid.Field.
|
|
@@ -976,4 +1138,233 @@
|
|
|
976
1138
|
|
|
977
1139
|
|
|
978
1140
|
jsGrid.fields.XDateTimeField = XDateTimeField;
|
|
979
|
-
}(jsGrid, jQuery));
|
|
1141
|
+
}(jsGrid, jQuery));
|
|
1142
|
+
(function(jsGrid, $, undefined) {
|
|
1143
|
+
|
|
1144
|
+
// Already standalone - the native control field extends jsGrid.Field
|
|
1145
|
+
// directly, same as every X-field. X-branded purely for naming parity,
|
|
1146
|
+
// so it can be used instead of "control" once the native fields bundle
|
|
1147
|
+
// is dropped in favor of the X set.
|
|
1148
|
+
|
|
1149
|
+
var Field = jsGrid.Field;
|
|
1150
|
+
|
|
1151
|
+
function Xcontrol(config) {
|
|
1152
|
+
Field.call(this, config);
|
|
1153
|
+
this.includeInDataExport = false;
|
|
1154
|
+
this._configInitialized = false;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
Xcontrol.prototype = new Field({
|
|
1158
|
+
css: "jsgrid-control-field",
|
|
1159
|
+
align: "center",
|
|
1160
|
+
width: 50,
|
|
1161
|
+
filtering: false,
|
|
1162
|
+
inserting: false,
|
|
1163
|
+
editing: false,
|
|
1164
|
+
sorting: false,
|
|
1165
|
+
|
|
1166
|
+
buttonClass: "jsgrid-button",
|
|
1167
|
+
modeButtonClass: "jsgrid-mode-button",
|
|
1168
|
+
|
|
1169
|
+
modeOnButtonClass: "jsgrid-mode-on-button",
|
|
1170
|
+
searchModeButtonClass: "jsgrid-search-mode-button",
|
|
1171
|
+
insertModeButtonClass: "jsgrid-insert-mode-button",
|
|
1172
|
+
editButtonClass: "jsgrid-edit-button",
|
|
1173
|
+
deleteButtonClass: "jsgrid-delete-button",
|
|
1174
|
+
searchButtonClass: "jsgrid-search-button",
|
|
1175
|
+
clearFilterButtonClass: "jsgrid-clear-filter-button",
|
|
1176
|
+
insertButtonClass: "jsgrid-insert-button",
|
|
1177
|
+
updateButtonClass: "jsgrid-update-button",
|
|
1178
|
+
cancelEditButtonClass: "jsgrid-cancel-edit-button",
|
|
1179
|
+
|
|
1180
|
+
searchModeButtonTooltip: "Switch to searching",
|
|
1181
|
+
insertModeButtonTooltip: "Switch to inserting",
|
|
1182
|
+
editButtonTooltip: "Edit",
|
|
1183
|
+
deleteButtonTooltip: "Delete",
|
|
1184
|
+
searchButtonTooltip: "Search",
|
|
1185
|
+
clearFilterButtonTooltip: "Clear filter",
|
|
1186
|
+
insertButtonTooltip: "Insert",
|
|
1187
|
+
updateButtonTooltip: "Update",
|
|
1188
|
+
cancelEditButtonTooltip: "Cancel edit",
|
|
1189
|
+
|
|
1190
|
+
editButton: true,
|
|
1191
|
+
deleteButton: true,
|
|
1192
|
+
clearFilterButton: true,
|
|
1193
|
+
modeSwitchButton: true,
|
|
1194
|
+
|
|
1195
|
+
_initConfig: function() {
|
|
1196
|
+
this._hasFiltering = this._grid.filtering;
|
|
1197
|
+
this._hasInserting = this._grid.inserting;
|
|
1198
|
+
|
|
1199
|
+
if(this._hasInserting && this.modeSwitchButton) {
|
|
1200
|
+
this._grid.inserting = false;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
this._configInitialized = true;
|
|
1204
|
+
},
|
|
1205
|
+
|
|
1206
|
+
headerTemplate: function() {
|
|
1207
|
+
if(!this._configInitialized) {
|
|
1208
|
+
this._initConfig();
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
var hasFiltering = this._hasFiltering;
|
|
1212
|
+
var hasInserting = this._hasInserting;
|
|
1213
|
+
|
|
1214
|
+
if(!this.modeSwitchButton || (!hasFiltering && !hasInserting))
|
|
1215
|
+
return "";
|
|
1216
|
+
|
|
1217
|
+
if(hasFiltering && !hasInserting)
|
|
1218
|
+
return this._createFilterSwitchButton();
|
|
1219
|
+
|
|
1220
|
+
if(hasInserting && !hasFiltering)
|
|
1221
|
+
return this._createInsertSwitchButton();
|
|
1222
|
+
|
|
1223
|
+
return this._createModeSwitchButton();
|
|
1224
|
+
},
|
|
1225
|
+
|
|
1226
|
+
itemTemplate: function(value, item) {
|
|
1227
|
+
var $result = $([]);
|
|
1228
|
+
|
|
1229
|
+
if(this.editButton) {
|
|
1230
|
+
$result = $result.add(this._createEditButton(item));
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
if(this.deleteButton) {
|
|
1234
|
+
$result = $result.add(this._createDeleteButton(item));
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
return $result;
|
|
1238
|
+
},
|
|
1239
|
+
|
|
1240
|
+
filterTemplate: function() {
|
|
1241
|
+
var $result = this._createSearchButton();
|
|
1242
|
+
return this.clearFilterButton ? $result.add(this._createClearFilterButton()) : $result;
|
|
1243
|
+
},
|
|
1244
|
+
|
|
1245
|
+
insertTemplate: function() {
|
|
1246
|
+
return this._createInsertButton();
|
|
1247
|
+
},
|
|
1248
|
+
|
|
1249
|
+
editTemplate: function() {
|
|
1250
|
+
return this._createUpdateButton().add(this._createCancelEditButton());
|
|
1251
|
+
},
|
|
1252
|
+
|
|
1253
|
+
_createFilterSwitchButton: function() {
|
|
1254
|
+
return this._createOnOffSwitchButton("filtering", this.searchModeButtonClass, true);
|
|
1255
|
+
},
|
|
1256
|
+
|
|
1257
|
+
_createInsertSwitchButton: function() {
|
|
1258
|
+
return this._createOnOffSwitchButton("inserting", this.insertModeButtonClass, false);
|
|
1259
|
+
},
|
|
1260
|
+
|
|
1261
|
+
_createOnOffSwitchButton: function(option, cssClass, isOnInitially) {
|
|
1262
|
+
var isOn = isOnInitially;
|
|
1263
|
+
|
|
1264
|
+
var updateButtonState = $.proxy(function() {
|
|
1265
|
+
$button.toggleClass(this.modeOnButtonClass, isOn);
|
|
1266
|
+
}, this);
|
|
1267
|
+
|
|
1268
|
+
var $button = this._createGridButton(this.modeButtonClass + " " + cssClass, "", function(grid) {
|
|
1269
|
+
isOn = !isOn;
|
|
1270
|
+
grid.option(option, isOn);
|
|
1271
|
+
updateButtonState();
|
|
1272
|
+
});
|
|
1273
|
+
|
|
1274
|
+
updateButtonState();
|
|
1275
|
+
|
|
1276
|
+
return $button;
|
|
1277
|
+
},
|
|
1278
|
+
|
|
1279
|
+
_createModeSwitchButton: function() {
|
|
1280
|
+
var isInserting = false;
|
|
1281
|
+
|
|
1282
|
+
var updateButtonState = $.proxy(function() {
|
|
1283
|
+
$button.attr("title", isInserting ? this.searchModeButtonTooltip : this.insertModeButtonTooltip)
|
|
1284
|
+
.toggleClass(this.insertModeButtonClass, !isInserting)
|
|
1285
|
+
.toggleClass(this.searchModeButtonClass, isInserting);
|
|
1286
|
+
}, this);
|
|
1287
|
+
|
|
1288
|
+
var $button = this._createGridButton(this.modeButtonClass, "", function(grid) {
|
|
1289
|
+
isInserting = !isInserting;
|
|
1290
|
+
grid.option("inserting", isInserting);
|
|
1291
|
+
grid.option("filtering", !isInserting);
|
|
1292
|
+
updateButtonState();
|
|
1293
|
+
});
|
|
1294
|
+
|
|
1295
|
+
updateButtonState();
|
|
1296
|
+
|
|
1297
|
+
return $button;
|
|
1298
|
+
},
|
|
1299
|
+
|
|
1300
|
+
_createEditButton: function(item) {
|
|
1301
|
+
return this._createGridButton(this.editButtonClass, this.editButtonTooltip, function(grid, e) {
|
|
1302
|
+
grid.editItem(item);
|
|
1303
|
+
e.stopPropagation();
|
|
1304
|
+
});
|
|
1305
|
+
},
|
|
1306
|
+
|
|
1307
|
+
_createDeleteButton: function(item) {
|
|
1308
|
+
return this._createGridButton(this.deleteButtonClass, this.deleteButtonTooltip, function(grid, e) {
|
|
1309
|
+
grid.deleteItem(item);
|
|
1310
|
+
e.stopPropagation();
|
|
1311
|
+
});
|
|
1312
|
+
},
|
|
1313
|
+
|
|
1314
|
+
_createSearchButton: function() {
|
|
1315
|
+
return this._createGridButton(this.searchButtonClass, this.searchButtonTooltip, function(grid) {
|
|
1316
|
+
grid.search();
|
|
1317
|
+
});
|
|
1318
|
+
},
|
|
1319
|
+
|
|
1320
|
+
_createClearFilterButton: function() {
|
|
1321
|
+
return this._createGridButton(this.clearFilterButtonClass, this.clearFilterButtonTooltip, function(grid) {
|
|
1322
|
+
grid.clearFilter();
|
|
1323
|
+
});
|
|
1324
|
+
},
|
|
1325
|
+
|
|
1326
|
+
_createInsertButton: function() {
|
|
1327
|
+
return this._createGridButton(this.insertButtonClass, this.insertButtonTooltip, function(grid) {
|
|
1328
|
+
grid.insertItem().done(function() {
|
|
1329
|
+
grid.clearInsert();
|
|
1330
|
+
});
|
|
1331
|
+
});
|
|
1332
|
+
},
|
|
1333
|
+
|
|
1334
|
+
_createUpdateButton: function() {
|
|
1335
|
+
return this._createGridButton(this.updateButtonClass, this.updateButtonTooltip, function(grid, e) {
|
|
1336
|
+
grid.updateItem();
|
|
1337
|
+
e.stopPropagation();
|
|
1338
|
+
});
|
|
1339
|
+
},
|
|
1340
|
+
|
|
1341
|
+
_createCancelEditButton: function() {
|
|
1342
|
+
return this._createGridButton(this.cancelEditButtonClass, this.cancelEditButtonTooltip, function(grid, e) {
|
|
1343
|
+
grid.cancelEdit();
|
|
1344
|
+
e.stopPropagation();
|
|
1345
|
+
});
|
|
1346
|
+
},
|
|
1347
|
+
|
|
1348
|
+
_createGridButton: function(cls, tooltip, clickHandler) {
|
|
1349
|
+
var grid = this._grid;
|
|
1350
|
+
|
|
1351
|
+
return $("<input>").addClass(this.buttonClass)
|
|
1352
|
+
.addClass(cls)
|
|
1353
|
+
.attr({
|
|
1354
|
+
type: "button",
|
|
1355
|
+
title: tooltip
|
|
1356
|
+
})
|
|
1357
|
+
.on("click", function(e) {
|
|
1358
|
+
clickHandler(grid, e);
|
|
1359
|
+
});
|
|
1360
|
+
},
|
|
1361
|
+
|
|
1362
|
+
editValue: function() {
|
|
1363
|
+
return "";
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
jsGrid.fields.Xcontrol = Xcontrol;
|
|
1369
|
+
|
|
1370
|
+
}(jsGrid, jQuery));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* jsxgrid v2.
|
|
2
|
+
* jsxgrid v2.1.0 (https://github.com/rok9ru/jsxgrid#readme)
|
|
3
3
|
* (c) 2026 Mikhail Kremza
|
|
4
4
|
* Licensed under MIT
|
|
5
5
|
*/
|
|
6
|
-
((t,l)=>{t?t.popup=t.popupBasic=function(t,e){this.idcounter=this.idcounter||0,this.idcounter++,(e=e||{}).closeText=e.closeText||"Close",e.heading=e.heading||"",e.styles=e.styles||".jsGridpopupBasicOverlay { position: fixed; top: 0; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, 0.7); transition: opacity 500ms; opacity: 1;}.jsGridpopupBasicPopup { margin: 70px auto; padding: 20px; min-height: 60%; background: #fff; border-radius: 5px; width: 60%; position: relative; transition: all 300ms ease-in-out;}.jsGridpopupBasicPopup h2 { margin-top: 0; color: #333; font-family: Tahoma, Arial, sans-serif;}.jsGridpopupBasicPopup .close { position: absolute; top: 10px; right: 30px; transition: all 200ms; font-size: 30px; font-weight: bold; text-decoration: none; color: #333;}.jsGridpopupBasicPopup .close:hover { color: #06D85F;}.jsGridpopupBasicPopup .jsGridpopupBasicContent { max-height: 30%; overflow: auto;}@media screen and (max-width: 700px){ .jsGridpopupBasicPopup{ width: 70%; }}",l("#jsGridpopupBasicStyles").length||(r=(i=l("head")).find("link[rel='stylesheet']:last"),n="<style id='jsGridpopupBasicStyles'>"+e.styles+"</style>",r.length?r.after(n):i.append(n));var i,n,r="jsGridpopupBasic"+this.idcounter,s=l('<div id="'+r+'" class="jsGridpopupBasicOverlay"><div class="jsGridpopupBasicPopup"><h2></h2><a class="close" href="#">×</a><div class="jsGridpopupBasicContent"></div></div></div>');return s.find("h2").text(e.heading),s.find(".jsGridpopupBasicContent").append(t),s.find(".close").click(function(){e.onClose instanceof Function&&e.onClose(s),s.remove()}),l("body").append(s),{id:r,$popup:s,hide:function(){s.remove()}}}:console.log("jsGrid is not defined!")})(jsGrid,jQuery),(s=>{var e=s.fn.jsGrid;e&&(s.fn.jsGrid=function(t){var r;return"object"==typeof t&&(r=t.onRefreshed,t.onRefreshed=function(t){r&&r.apply(this,arguments);var t=t.grid,i=t.option("data")||[],e=t.option("fields")||[],t=t._container.find(".jsgrid-table").last(),t=(t.find(".jsgrid-summary-footer").remove(),s("<tfoot class='jsgrid-summary-footer'>").appendTo(t)),n=s("<tr>").addClass("jsgrid-row").css({background:"#e1e1e1","font-weight":"bold"}).appendTo(t);e.forEach(function(t){var e=s("<td>").addClass("jsgrid-cell").appendTo(n);"function"==typeof t.summary&&(t=t.summary.call(t,i),e.html(t))})}),e.apply(this,arguments)})})(jQuery),((t,i)=>{function e(t){n.call(this,t)}var n=t.Field;e.prototype=new n({sorter:"number",align:"center",autosearch:!0,defaultSelected:null,filterTemplate:function(){var t,e;return this.filtering?(t=this._grid,(e=this.filterControl=this._createCheckbox()).prop({readOnly:!0,indeterminate:!0}),e.on("click",function(){var t=i(this);t.prop("readOnly")?t.prop({checked:!1,readOnly:!1}):t.prop("checked")||t.prop({readOnly:!0,indeterminate:!0})}),this.autosearch&&e.on("click",function(){t.search()}),null!==this.defaultSelected&&(e.prop({checked:!!this.defaultSelected,indeterminate:!1,readOnly:!1}),this.defaultSelected=null),e):""},filterValue:function(){return this.filterControl.get(0).indeterminate?void 0:this.filterControl.is(":checked")?1:0},insertTemplate:function(){return this.inserting?this.insertControl=this._createCheckbox():""},insertValue:function(){return+this.insertControl.is(":checked")},editValue:function(){return+this.editControl.is(":checked")},itemTemplate:function(t){return this._createCheckbox().prop({checked:+t,disabled:!0})},editTemplate:function(t){var e;return this.editing?((e=this.editControl=this._createCheckbox()).prop("checked",+t),e):this.itemTemplate.apply(this,arguments)},_createCheckbox:function(){return i("<input>").attr("type","checkbox")}}),t.fields.Xcheckbox=e})(jsGrid,jQuery),((t,n)=>{function e(t){i.call(this,t)}var i=t.Field;e.prototype=new i({autosearch:!0,readOnly:!1,fm_callback:null,editButtonText:"Open FM",defaultSelected:null,filterTemplate:function(){var e,t;return this.filtering?(e=this._grid,t=this.filterControl=this._createTextBox(),this.autosearch&&t.on("keypress",function(t){13===t.which&&(e.search(),t.preventDefault())}),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),t):""},filterValue:function(){return this.filterControl.val()},itemTemplate:function(t){var e=n('<img class="jsgrid-img" src="">');return e.attr("src",t||""),e.css("max-height","50px"),e.css("max-width","50px"),e},editTemplate:function(t){var e,i;return this.editing?(e=this.fm_callback,i=this.editControl=n('<input type="text">').val(t||""),e?n('<button class="jsgrid-imgField-button">'+this.editButtonText+"</button>").click(function(){e(i)}):i):this.itemTemplate.apply(this,arguments)},insertTemplate:function(){var t,e;return this.inserting?(t=this.fm_callback,e=this.insertControl=n('<input type="text">'),"function"==typeof t?n('<button class="jsgrid-imgField-button">'+this.editButtonText+"</button>").click(function(){t(e)}):e):""},insertValue:function(){return this.insertControl.val()},editValue:function(){return this.editControl.val()},_createTextBox:function(){return n("<input>").attr("type","text").prop("readonly",!!this.readOnly)}}),t.fields.XimgField=e})(jsGrid,jQuery),((t,o)=>{function e(t){var e;this.items=[],this.selectedIndex=-1,this.valueField="",this.textField="",t.valueField&&t.items&&t.items.length&&(e=t.items[0][t.valueField],this.valueType=typeof e==n?n:"string"),this.sorter=this.valueType,i.call(this,t)}var i=t.Field,n="number";e.prototype=new i({align:"center",autosearch:!0,valueType:n,pseudoElement:null,select2:null,defaultSelected:null,itemTemplate:function(e){var t=this.items,i=this.valueField,n=this.textField,t=i?"object"==typeof e?e:o.grep(t,function(t){return t[i]===e})[0]||{}:t[e],n=n?t[n]:t;return null==n?"":n},insertTemplate:function(){return this.inserting?this.insertControl=this._createSelect():""},editTemplate:function(t){var e,i;return this.editing?(e=this.editControl=this._createSelect(),void 0!==(i="object"==typeof(i=t)?t[this.valueField]:t)&&e.val(i),e):this.itemTemplate.apply(this,arguments)},insertValue:function(){var t=this.insertControl.val();return this.valueType===n?parseInt(t||0,10):t},editValue:function(){var t=this.editControl.val();return this.valueType===n?parseInt(t||0,10):t},filterTemplate:function(){var t,i,n,r,e,s;return this.filtering?(Array.isArray(this.items)?(t=this.items.slice(0),this.pseudoElement?t.unshift(this.pseudoElement):((s={})[this.textField]="",s[this.valueField]=null,t.unshift(s))):"object"==typeof this.items&&(t=Object.assign({},this.items),t="object"==typeof this.pseudoElement&&this.pseudoElement?Object.assign({},t,this.pseudoElement):Object.assign({},{"":null},t)),null!==this.defaultSelected&&(i=this.valueField,n=this.defaultSelected,r=-1,o.each(t,function(t,e){if((i?e[i]:t)==n)return r=t,!1}),-1!==r&&(this.selectedIndex=r),this.defaultSelected=null),e=this._grid,s=this.filterControl=this._createSelect(t),this.autosearch&&s.on("change",function(t){e.search()}),s):""},filterValue:function(){var t=this.filterControl.val();return this.valueType===n?parseInt(t||0,10):t},_createSelect:function(t){var e,n=o("<select>"),r=this.valueField,s=this.textField,l=this.selectedIndex;return o.each(t||this.items,function(t,e){var i=r?e[r]:t,e=s?e[s]:e;o("<option>").attr("value",i).text(e).appendTo(n).prop("selected",l===t)}),n.prop("disabled",!!this.readOnly),this.select2&&(e=Object.assign({},this.select2,{width:"100%"}),setTimeout(function(){n.select2(e)},0)),n}}),t.fields.Xselect=e})(jsGrid,jQuery),((t,r)=>{function e(t){i.call(this,t)}var i=t.Field;e.prototype=new i({autosearch:!0,readOnly:!1,maxShowSymbols:50,defaultSelected:null,filterTemplate:function(){var e,t;return this.filtering?(e=this._grid,t=this.filterControl=this._createTextBox(),this.autosearch&&t.on("keypress",function(t){13===t.which&&(e.search(),t.preventDefault())}),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),t):""},filterValue:function(){return this.filterControl.val()},insertTemplate:function(){return this.inserting?this.insertControl=this._createTextArea():""},editTemplate:function(t){var e;return this.editing?((e=this.editControl=this._createTextArea()).val(t),e):this.itemTemplate.apply(this,arguments)},insertValue:function(){return this.insertControl.val()},editValue:function(){return this.editControl.val()},_createTextBox:function(){return r("<input>").attr("type","text").prop("readonly",!!this.readOnly)},_createTextArea:function(){return r("<textarea>").prop("readonly",!!this.readOnly)},itemTemplate:function(t,e){var i,n;return(t=null==t?"":String(t)).length<=this.maxShowSymbols?r("<div>").text(t):(i=t.slice(0,this.maxShowSymbols),n=r("<div>").text(i+" ...").one("click",function(){return n.text(t),!1}))}}),t.fields.Xtextarea=e})(jsGrid,jQuery),((n,r)=>{function t(t){e.call(this,t)}var e=n.Field;t.prototype=new e({autosearch:!0,readOnly:!1,templates:[],closeText:"Save",editText:"Editor",defaultSelected:null,filterTemplate:function(){var e,t;return this.filtering?(e=this._grid,t=this.filterControl=this._createTextBox(),this.autosearch&&t.on("keypress",function(t){13===t.which&&(e.search(),t.preventDefault())}),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),t):""},filterValue:function(){return this.filterControl.val()},insertValue:function(){return this.insertControl.val()},editValue:function(){return this.editControl.val()},_createTextBox:function(){return r("<input>").attr("type","text").prop("readonly",!!this.readOnly)},_doModal:function(t,e,i){return n.popup(t,e)},_createJsonEditor:function(t,e){if("undefined"==typeof JSONEditor)throw new Error("Xjsoneditor requires the 'jsoneditor' package to be loaded on the page.");"object"!=typeof(t=t||{})&&(t=JSON.parse(t));var i=r('<div style="height: 500px;">'),e=(r("body").append(i),i=i[0],{templates:this.templates,modes:["code","text","tree"],onError:function(t){alert(t.toString())},mode:e||"view"});return new JSONEditor(i,e,t)},itemTemplate:function(e,t){var i=this;return r("<button>"+i.editText+"</button>").click(function(){var t=i._createJsonEditor(e);return i._doModal(t.container,{onClose:function(){r(t.container).remove(),t.destroy()}}),!1})},insertTemplate:function(){var t;return this.inserting?(t=this).insertControl=r("<textarea>").click(function(){var e=t._createJsonEditor({},"tree"),i=r(this);return t._doModal(e.container,{closeText:t.closeText,onClose:function(){var t=e.get();r.isEmptyObject(t)?i.val({}):i.val(JSON.stringify(t)),e.destroy()}}),!1}):""},editTemplate:function(t){var n;return this.editing?(n=this).editControl=r("<textarea>").val(t).click(function(){var e=r(this),i=n._createJsonEditor(e.val(),"tree");return n._doModal(i.container,{closeText:n.closeText,onClose:function(){var t=i.get();r.isEmptyObject(t)?e.val({}):e.val(JSON.stringify(t)),i.destroy()}}),!1}):this.itemTemplate.apply(this,arguments)}}),n.fields.Xjsoneditor=t})(jsGrid,jQuery),((e,n)=>{function t(t){this.selectedItems=[],this.uid=Date.now().toString(36)+Math.random().toString(36).substring(2),e.Field.call(this,t)}t.prototype=new e.Field({filtering:!1,deleteItemByItem:!1,buttonText:"",selectedItemsAction:function(t){},unselectAll:function(){this.selectedItems=[],this._grid._container.find("[data-uid='"+this.uid+"'] ").prop("checked",!1)},headerTemplate:function(){var e;return this.buttonText?(e=this,n("<button>").attr("type","button").text(e.buttonText).on("click",function(t){e.selectedItemsAction(e.selectedItems),t.stopPropagation()})):""},itemTemplate:function(t,e){var i=this;return n("<input data-uid='"+i.uid+"' type='checkbox'>").prop("checked",-1<n.inArray(e,i.selectedItems)).on("change",function(){n(this).is(":checked")?i.selectItem(e):i.unselectItem(e)}).click(function(t){t.stopPropagation()})},editTemplate:function(){return""},align:"center",selectItem:function(t){this.selectedItems.push(t)},unselectItem:function(e){this.selectedItems=n.grep(this.selectedItems,function(t){return t!==e})}}),e.fields.XRowSelectField=t})(jsGrid,jQuery),((e,s)=>{function t(t){e.Field.call(this,t)}t.prototype=new e.Field({css:"date-field",align:"center",datePickerType:"datetime-local",dateRange:!1,defaultSelected:null,sorter:function(t,e){return new Date(t)-new Date(e)},filterTemplate:function(){var e,t,i,n,r;return this.filtering?(e=this._grid,t=s(),this.dateRange?(r=s("<div class='jsgrid-date-range-wrapper'>"),i=s("<input>",{class:"jsgrid-date-picker jsgrid-date-start",type:this.datePickerType,title:"Period date start"}),n=s("<input>",{class:"jsgrid-date-picker jsgrid-date-end",type:this.datePickerType,title:"Period date end"}),r.val=function(){return{from:i.val(),to:n.val()}},t=this.filterControl=r.append(i).append(n),null!==this.defaultSelected&&(r=this.defaultSelected||{},i.val(r.from||""),n.val(r.to||""),this.defaultSelected=null),this.autosearch&&t.on("change",".jsgrid-date-picker",function(t){e.search()})):(t=this.filterControl=this._createPicker(),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),this.autosearch&&t.on("change",function(t){e.search()})),t):""},filterValue:function(){return this.filterControl.val()},itemTemplate:function(t){var e;return t?(e=this.options||{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"},new Date(t.replace(" ","T")).toLocaleDateString(void 0,e)):""},insertTemplate:function(){return this._insertPicker=this._createPicker()},editTemplate:function(t){return this._editPicker=this._createPicker().val(t)},insertValue:function(){return this._insertPicker.val()},editValue:function(){return this._editPicker.val()},_createPicker:function(){return s("<input class='date-picker'>").attr("type",this.datePickerType)}}),e.fields.XDateTimeField=t})(jsGrid,jQuery);
|
|
6
|
+
((t,s)=>{t?t.popup=t.popupBasic=function(t,e){this.idcounter=this.idcounter||0,this.idcounter++,(e=e||{}).closeText=e.closeText||"Close",e.heading=e.heading||"",e.styles=e.styles||".jsGridpopupBasicOverlay { position: fixed; top: 0; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, 0.7); transition: opacity 500ms; opacity: 1;}.jsGridpopupBasicPopup { margin: 70px auto; padding: 20px; min-height: 60%; background: #fff; border-radius: 5px; width: 60%; position: relative; transition: all 300ms ease-in-out;}.jsGridpopupBasicPopup h2 { margin-top: 0; color: #333; font-family: Tahoma, Arial, sans-serif;}.jsGridpopupBasicPopup .close { position: absolute; top: 10px; right: 30px; transition: all 200ms; font-size: 30px; font-weight: bold; text-decoration: none; color: #333;}.jsGridpopupBasicPopup .close:hover { color: #06D85F;}.jsGridpopupBasicPopup .jsGridpopupBasicContent { max-height: 30%; overflow: auto;}@media screen and (max-width: 700px){ .jsGridpopupBasicPopup{ width: 70%; }}",s("#jsGridpopupBasicStyles").length||(r=(i=s("head")).find("link[rel='stylesheet']:last"),n="<style id='jsGridpopupBasicStyles'>"+e.styles+"</style>",r.length?r.after(n):i.append(n));var i,n,r="jsGridpopupBasic"+this.idcounter,o=s('<div id="'+r+'" class="jsGridpopupBasicOverlay"><div class="jsGridpopupBasicPopup"><h2></h2><a class="close" href="#">×</a><div class="jsGridpopupBasicContent"></div></div></div>');return o.find("h2").text(e.heading),o.find(".jsGridpopupBasicContent").append(t),o.find(".close").click(function(){e.onClose instanceof Function&&e.onClose(o),o.remove()}),s("body").append(o),{id:r,$popup:o,hide:function(){o.remove()}}}:console.log("jsGrid is not defined!")})(jsGrid,jQuery),(o=>{var e=o.fn.jsGrid;e&&(o.fn.jsGrid=function(t){var r;return"object"==typeof t&&(r=t.onRefreshed,t.onRefreshed=function(t){r&&r.apply(this,arguments);var t=t.grid,i=t.option("data")||[],e=t.option("fields")||[],t=t._container.find(".jsgrid-table").last(),t=(t.find(".jsgrid-summary-footer").remove(),o("<tfoot class='jsgrid-summary-footer'>").appendTo(t)),n=o("<tr>").addClass("jsgrid-row").css({background:"#e1e1e1","font-weight":"bold"}).appendTo(t);e.forEach(function(t){var e=o("<td>").addClass("jsgrid-cell").appendTo(n);"function"==typeof t.summary&&(t=t.summary.call(t,i),e.html(t))})}),e.apply(this,arguments)})})(jQuery),((t,e)=>{function i(t){n.call(this,t)}var n=t.Field;i.prototype=new n({autosearch:!0,readOnly:!1,defaultSelected:null,filterTemplate:function(){var e,t;return this.filtering?(e=this._grid,t=this.filterControl=this._createTextBox(),this.autosearch&&t.on("keypress",function(t){13===t.which&&(e.search(),t.preventDefault())}),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),t):""},insertTemplate:function(){return this.inserting?this.insertControl=this._createTextBox():""},editTemplate:function(t){var e;return this.editing?((e=this.editControl=this._createTextBox()).val(t),e):this.itemTemplate.apply(this,arguments)},filterValue:function(){return this.filterControl.val()},insertValue:function(){return this.insertControl.val()},editValue:function(){return this.editControl.val()},_createTextBox:function(){return e("<input>").attr("type","text").prop("readonly",!!this.readOnly)}}),t.fields.Xtext=i})(jsGrid,jQuery),((t,e,i)=>{function n(t){r.call(this,t)}var r=t.Field;n.prototype=new r({sorter:"number",align:"right",autosearch:!0,readOnly:!1,defaultSelected:null,filterTemplate:function(){var e,t;return this.filtering?(e=this._grid,t=this.filterControl=this._createTextBox(),this.autosearch&&t.on("keypress",function(t){13===t.which&&(e.search(),t.preventDefault())}),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),t):""},insertTemplate:function(){return this.inserting?this.insertControl=this._createTextBox():""},editTemplate:function(t){var e;return this.editing?((e=this.editControl=this._createTextBox()).val(t),e):this.itemTemplate.apply(this,arguments)},filterValue:function(){return this.filterControl.val()?parseInt(this.filterControl.val()||0,10):i},insertValue:function(){return this.insertControl.val()?parseInt(this.insertControl.val()||0,10):i},editValue:function(){return this.editControl.val()?parseInt(this.editControl.val()||0,10):i},_createTextBox:function(){return e("<input>").attr("type","number").prop("readonly",!!this.readOnly)}}),t.fields.Xnumber=n})(jsGrid,jQuery),((t,i)=>{function e(t){n.call(this,t)}var n=t.Field;e.prototype=new n({sorter:"number",align:"center",autosearch:!0,defaultSelected:null,filterTemplate:function(){var t,e;return this.filtering?(t=this._grid,(e=this.filterControl=this._createCheckbox()).prop({readOnly:!0,indeterminate:!0}),e.on("click",function(){var t=i(this);t.prop("readOnly")?t.prop({checked:!1,readOnly:!1}):t.prop("checked")||t.prop({readOnly:!0,indeterminate:!0})}),this.autosearch&&e.on("click",function(){t.search()}),null!==this.defaultSelected&&(e.prop({checked:!!this.defaultSelected,indeterminate:!1,readOnly:!1}),this.defaultSelected=null),e):""},filterValue:function(){return this.filterControl.get(0).indeterminate?void 0:this.filterControl.is(":checked")?1:0},insertTemplate:function(){return this.inserting?this.insertControl=this._createCheckbox():""},insertValue:function(){return+this.insertControl.is(":checked")},editValue:function(){return+this.editControl.is(":checked")},itemTemplate:function(t){return this._createCheckbox().prop({checked:+t,disabled:!0})},editTemplate:function(t){var e;return this.editing?((e=this.editControl=this._createCheckbox()).prop("checked",+t),e):this.itemTemplate.apply(this,arguments)},_createCheckbox:function(){return i("<input>").attr("type","checkbox")}}),t.fields.Xcheckbox=e})(jsGrid,jQuery),((t,n)=>{function e(t){i.call(this,t)}var i=t.Field;e.prototype=new i({autosearch:!0,readOnly:!1,fm_callback:null,editButtonText:"Open FM",defaultSelected:null,filterTemplate:function(){var e,t;return this.filtering?(e=this._grid,t=this.filterControl=this._createTextBox(),this.autosearch&&t.on("keypress",function(t){13===t.which&&(e.search(),t.preventDefault())}),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),t):""},filterValue:function(){return this.filterControl.val()},itemTemplate:function(t){var e=n('<img class="jsgrid-img" src="">');return e.attr("src",t||""),e.css("max-height","50px"),e.css("max-width","50px"),e},editTemplate:function(t){var e,i;return this.editing?(e=this.fm_callback,i=this.editControl=n('<input type="text">').val(t||""),e?n('<button class="jsgrid-imgField-button">'+this.editButtonText+"</button>").click(function(){e(i)}):i):this.itemTemplate.apply(this,arguments)},insertTemplate:function(){var t,e;return this.inserting?(t=this.fm_callback,e=this.insertControl=n('<input type="text">'),"function"==typeof t?n('<button class="jsgrid-imgField-button">'+this.editButtonText+"</button>").click(function(){t(e)}):e):""},insertValue:function(){return this.insertControl.val()},editValue:function(){return this.editControl.val()},_createTextBox:function(){return n("<input>").attr("type","text").prop("readonly",!!this.readOnly)}}),t.fields.XimgField=e})(jsGrid,jQuery),((t,l)=>{function e(t){var e;this.items=[],this.selectedIndex=-1,this.valueField="",this.textField="",t.valueField&&t.items&&t.items.length&&(e=t.items[0][t.valueField],this.valueType=typeof e==n?n:"string"),this.sorter=this.valueType,i.call(this,t)}var i=t.Field,n="number";e.prototype=new i({align:"center",autosearch:!0,valueType:n,pseudoElement:null,select2:null,defaultSelected:null,itemTemplate:function(e){var t=this.items,i=this.valueField,n=this.textField,t=i?"object"==typeof e?e:l.grep(t,function(t){return t[i]===e})[0]||{}:t[e],n=n?t[n]:t;return null==n?"":n},insertTemplate:function(){return this.inserting?this.insertControl=this._createSelect():""},editTemplate:function(t){var e,i;return this.editing?(e=this.editControl=this._createSelect(),void 0!==(i="object"==typeof(i=t)?t[this.valueField]:t)&&e.val(i),e):this.itemTemplate.apply(this,arguments)},insertValue:function(){var t=this.insertControl.val();return this.valueType===n?parseInt(t||0,10):t},editValue:function(){var t=this.editControl.val();return this.valueType===n?parseInt(t||0,10):t},filterTemplate:function(){var t,i,n,r,e,o;return this.filtering?(Array.isArray(this.items)?(t=this.items.slice(0),this.pseudoElement?t.unshift(this.pseudoElement):((o={})[this.textField]="",o[this.valueField]=null,t.unshift(o))):"object"==typeof this.items&&(t=Object.assign({},this.items),t="object"==typeof this.pseudoElement&&this.pseudoElement?Object.assign({},t,this.pseudoElement):Object.assign({},{"":null},t)),null!==this.defaultSelected&&(i=this.valueField,n=this.defaultSelected,r=-1,l.each(t,function(t,e){if((i?e[i]:t)==n)return r=t,!1}),-1!==r&&(this.selectedIndex=r),this.defaultSelected=null),e=this._grid,o=this.filterControl=this._createSelect(t),this.autosearch&&o.on("change",function(t){e.search()}),o):""},filterValue:function(){var t=this.filterControl.val();return this.valueType===n?parseInt(t||0,10):t},_createSelect:function(t){var e,n=l("<select>"),r=this.valueField,o=this.textField,s=this.selectedIndex;return l.each(t||this.items,function(t,e){var i=r?e[r]:t,e=o?e[o]:e;l("<option>").attr("value",i).text(e).appendTo(n).prop("selected",s===t)}),n.prop("disabled",!!this.readOnly),this.select2&&(e=Object.assign({},this.select2,{width:"100%"}),setTimeout(function(){n.select2(e)},0)),n}}),t.fields.Xselect=e})(jsGrid,jQuery),((t,r)=>{function e(t){i.call(this,t)}var i=t.Field;e.prototype=new i({autosearch:!0,readOnly:!1,maxShowSymbols:50,defaultSelected:null,filterTemplate:function(){var e,t;return this.filtering?(e=this._grid,t=this.filterControl=this._createTextBox(),this.autosearch&&t.on("keypress",function(t){13===t.which&&(e.search(),t.preventDefault())}),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),t):""},filterValue:function(){return this.filterControl.val()},insertTemplate:function(){return this.inserting?this.insertControl=this._createTextArea():""},editTemplate:function(t){var e;return this.editing?((e=this.editControl=this._createTextArea()).val(t),e):this.itemTemplate.apply(this,arguments)},insertValue:function(){return this.insertControl.val()},editValue:function(){return this.editControl.val()},_createTextBox:function(){return r("<input>").attr("type","text").prop("readonly",!!this.readOnly)},_createTextArea:function(){return r("<textarea>").prop("readonly",!!this.readOnly)},itemTemplate:function(t,e){var i,n;return(t=null==t?"":String(t)).length<=this.maxShowSymbols?r("<div>").text(t):(i=t.slice(0,this.maxShowSymbols),n=r("<div>").text(i+" ...").one("click",function(){return n.text(t),!1}))}}),t.fields.Xtextarea=e})(jsGrid,jQuery),((n,r)=>{function t(t){e.call(this,t)}var e=n.Field;t.prototype=new e({autosearch:!0,readOnly:!1,templates:[],closeText:"Save",editText:"Editor",defaultSelected:null,filterTemplate:function(){var e,t;return this.filtering?(e=this._grid,t=this.filterControl=this._createTextBox(),this.autosearch&&t.on("keypress",function(t){13===t.which&&(e.search(),t.preventDefault())}),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),t):""},filterValue:function(){return this.filterControl.val()},insertValue:function(){return this.insertControl.val()},editValue:function(){return this.editControl.val()},_createTextBox:function(){return r("<input>").attr("type","text").prop("readonly",!!this.readOnly)},_doModal:function(t,e,i){return n.popup(t,e)},_createJsonEditor:function(t,e){if("undefined"==typeof JSONEditor)throw new Error("Xjsoneditor requires the 'jsoneditor' package to be loaded on the page.");"object"!=typeof(t=t||{})&&(t=JSON.parse(t));var i=r('<div style="height: 500px;">'),e=(r("body").append(i),i=i[0],{templates:this.templates,modes:["code","text","tree"],onError:function(t){alert(t.toString())},mode:e||"view"});return new JSONEditor(i,e,t)},itemTemplate:function(e,t){var i=this;return r("<button>"+i.editText+"</button>").click(function(){var t=i._createJsonEditor(e);return i._doModal(t.container,{onClose:function(){r(t.container).remove(),t.destroy()}}),!1})},insertTemplate:function(){var t;return this.inserting?(t=this).insertControl=r("<textarea>").click(function(){var e=t._createJsonEditor({},"tree"),i=r(this);return t._doModal(e.container,{closeText:t.closeText,onClose:function(){var t=e.get();r.isEmptyObject(t)?i.val({}):i.val(JSON.stringify(t)),e.destroy()}}),!1}):""},editTemplate:function(t){var n;return this.editing?(n=this).editControl=r("<textarea>").val(t).click(function(){var e=r(this),i=n._createJsonEditor(e.val(),"tree");return n._doModal(i.container,{closeText:n.closeText,onClose:function(){var t=i.get();r.isEmptyObject(t)?e.val({}):e.val(JSON.stringify(t)),i.destroy()}}),!1}):this.itemTemplate.apply(this,arguments)}}),n.fields.Xjsoneditor=t})(jsGrid,jQuery),((e,n)=>{function t(t){this.selectedItems=[],this.uid=Date.now().toString(36)+Math.random().toString(36).substring(2),e.Field.call(this,t)}t.prototype=new e.Field({filtering:!1,deleteItemByItem:!1,buttonText:"",selectedItemsAction:function(t){},unselectAll:function(){this.selectedItems=[],this._grid._container.find("[data-uid='"+this.uid+"'] ").prop("checked",!1)},headerTemplate:function(){var e;return this.buttonText?(e=this,n("<button>").attr("type","button").text(e.buttonText).on("click",function(t){e.selectedItemsAction(e.selectedItems),t.stopPropagation()})):""},itemTemplate:function(t,e){var i=this;return n("<input data-uid='"+i.uid+"' type='checkbox'>").prop("checked",-1<n.inArray(e,i.selectedItems)).on("change",function(){n(this).is(":checked")?i.selectItem(e):i.unselectItem(e)}).click(function(t){t.stopPropagation()})},editTemplate:function(){return""},align:"center",selectItem:function(t){this.selectedItems.push(t)},unselectItem:function(e){this.selectedItems=n.grep(this.selectedItems,function(t){return t!==e})}}),e.fields.XRowSelectField=t})(jsGrid,jQuery),((e,o)=>{function t(t){e.Field.call(this,t)}t.prototype=new e.Field({css:"date-field",align:"center",datePickerType:"datetime-local",dateRange:!1,defaultSelected:null,sorter:function(t,e){return new Date(t)-new Date(e)},filterTemplate:function(){var e,t,i,n,r;return this.filtering?(e=this._grid,t=o(),this.dateRange?(r=o("<div class='jsgrid-date-range-wrapper'>"),i=o("<input>",{class:"jsgrid-date-picker jsgrid-date-start",type:this.datePickerType,title:"Period date start"}),n=o("<input>",{class:"jsgrid-date-picker jsgrid-date-end",type:this.datePickerType,title:"Period date end"}),r.val=function(){return{from:i.val(),to:n.val()}},t=this.filterControl=r.append(i).append(n),null!==this.defaultSelected&&(r=this.defaultSelected||{},i.val(r.from||""),n.val(r.to||""),this.defaultSelected=null),this.autosearch&&t.on("change",".jsgrid-date-picker",function(t){e.search()})):(t=this.filterControl=this._createPicker(),null!==this.defaultSelected&&(t.val(this.defaultSelected),this.defaultSelected=null),this.autosearch&&t.on("change",function(t){e.search()})),t):""},filterValue:function(){return this.filterControl.val()},itemTemplate:function(t){var e;return t?(e=this.options||{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"},new Date(t.replace(" ","T")).toLocaleDateString(void 0,e)):""},insertTemplate:function(){return this._insertPicker=this._createPicker()},editTemplate:function(t){return this._editPicker=this._createPicker().val(t)},insertValue:function(){return this._insertPicker.val()},editValue:function(){return this._editPicker.val()},_createPicker:function(){return o("<input class='date-picker'>").attr("type",this.datePickerType)}}),e.fields.XDateTimeField=t})(jsGrid,jQuery),((t,s)=>{var e=t.Field;function i(t){e.call(this,t),this.includeInDataExport=!1,this._configInitialized=!1}i.prototype=new e({css:"jsgrid-control-field",align:"center",width:50,filtering:!1,inserting:!1,editing:!1,sorting:!1,buttonClass:"jsgrid-button",modeButtonClass:"jsgrid-mode-button",modeOnButtonClass:"jsgrid-mode-on-button",searchModeButtonClass:"jsgrid-search-mode-button",insertModeButtonClass:"jsgrid-insert-mode-button",editButtonClass:"jsgrid-edit-button",deleteButtonClass:"jsgrid-delete-button",searchButtonClass:"jsgrid-search-button",clearFilterButtonClass:"jsgrid-clear-filter-button",insertButtonClass:"jsgrid-insert-button",updateButtonClass:"jsgrid-update-button",cancelEditButtonClass:"jsgrid-cancel-edit-button",searchModeButtonTooltip:"Switch to searching",insertModeButtonTooltip:"Switch to inserting",editButtonTooltip:"Edit",deleteButtonTooltip:"Delete",searchButtonTooltip:"Search",clearFilterButtonTooltip:"Clear filter",insertButtonTooltip:"Insert",updateButtonTooltip:"Update",cancelEditButtonTooltip:"Cancel edit",editButton:!0,deleteButton:!0,clearFilterButton:!0,modeSwitchButton:!0,_initConfig:function(){this._hasFiltering=this._grid.filtering,this._hasInserting=this._grid.inserting,this._hasInserting&&this.modeSwitchButton&&(this._grid.inserting=!1),this._configInitialized=!0},headerTemplate:function(){this._configInitialized||this._initConfig();var t=this._hasFiltering,e=this._hasInserting;return this.modeSwitchButton&&(t||e)?t&&!e?this._createFilterSwitchButton():e&&!t?this._createInsertSwitchButton():this._createModeSwitchButton():""},itemTemplate:function(t,e){var i=s([]);return this.editButton&&(i=i.add(this._createEditButton(e))),i=this.deleteButton?i.add(this._createDeleteButton(e)):i},filterTemplate:function(){var t=this._createSearchButton();return this.clearFilterButton?t.add(this._createClearFilterButton()):t},insertTemplate:function(){return this._createInsertButton()},editTemplate:function(){return this._createUpdateButton().add(this._createCancelEditButton())},_createFilterSwitchButton:function(){return this._createOnOffSwitchButton("filtering",this.searchModeButtonClass,!0)},_createInsertSwitchButton:function(){return this._createOnOffSwitchButton("inserting",this.insertModeButtonClass,!1)},_createOnOffSwitchButton:function(e,t,i){var n=i,r=s.proxy(function(){o.toggleClass(this.modeOnButtonClass,n)},this),o=this._createGridButton(this.modeButtonClass+" "+t,"",function(t){n=!n,t.option(e,n),r()});return r(),o},_createModeSwitchButton:function(){var e=!1,i=s.proxy(function(){t.attr("title",e?this.searchModeButtonTooltip:this.insertModeButtonTooltip).toggleClass(this.insertModeButtonClass,!e).toggleClass(this.searchModeButtonClass,e)},this),t=this._createGridButton(this.modeButtonClass,"",function(t){e=!e,t.option("inserting",e),t.option("filtering",!e),i()});return i(),t},_createEditButton:function(i){return this._createGridButton(this.editButtonClass,this.editButtonTooltip,function(t,e){t.editItem(i),e.stopPropagation()})},_createDeleteButton:function(i){return this._createGridButton(this.deleteButtonClass,this.deleteButtonTooltip,function(t,e){t.deleteItem(i),e.stopPropagation()})},_createSearchButton:function(){return this._createGridButton(this.searchButtonClass,this.searchButtonTooltip,function(t){t.search()})},_createClearFilterButton:function(){return this._createGridButton(this.clearFilterButtonClass,this.clearFilterButtonTooltip,function(t){t.clearFilter()})},_createInsertButton:function(){return this._createGridButton(this.insertButtonClass,this.insertButtonTooltip,function(t){t.insertItem().done(function(){t.clearInsert()})})},_createUpdateButton:function(){return this._createGridButton(this.updateButtonClass,this.updateButtonTooltip,function(t,e){t.updateItem(),e.stopPropagation()})},_createCancelEditButton:function(){return this._createGridButton(this.cancelEditButtonClass,this.cancelEditButtonTooltip,function(t,e){t.cancelEdit(),e.stopPropagation()})},_createGridButton:function(t,e,i){var n=this._grid;return s("<input>").addClass(this.buttonClass).addClass(t).attr({type:"button",title:e}).on("click",function(t){i(n,t)})},editValue:function(){return""}}),t.fields.Xcontrol=i})(jsGrid,jQuery);
|
package/dist/jsxgrid.css
CHANGED
package/dist/jsxgrid.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* jsxgrid v2.
|
|
2
|
+
* jsxgrid v2.1.0 (https://github.com/rok9ru/jsxgrid#readme)
|
|
3
3
|
* (c) 2026 Mikhail Kremza
|
|
4
4
|
* Licensed under MIT
|
|
5
5
|
*/
|
|
@@ -1655,7 +1655,7 @@
|
|
|
1655
1655
|
setDefaults: setDefaults,
|
|
1656
1656
|
locales: locales,
|
|
1657
1657
|
locale: locale,
|
|
1658
|
-
version: '2.
|
|
1658
|
+
version: '2.1.0'
|
|
1659
1659
|
};
|
|
1660
1660
|
|
|
1661
1661
|
}(window, jQuery));
|
package/dist/jsxgrid.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* jsxgrid v2.
|
|
2
|
+
* jsxgrid v2.1.0 (https://github.com/rok9ru/jsxgrid#readme)
|
|
3
3
|
* (c) 2026 Mikhail Kremza
|
|
4
4
|
* Licensed under MIT
|
|
5
5
|
*/
|
|
6
|
-
((e,c,u)=>{function a(t,e){return c.isFunction(t)?t.apply(e,c.makeArray(arguments).slice(2)):t}var n,s="JSGrid",o="JSGridItem",i="JSGridEditRow",r=[],d=0,l="asc",t={loadData:c.noop,insertItem:c.noop,updateItem:c.noop,deleteItem:c.noop};function h(t,e){t=c(t);0==r.length?(this._id=d,d++):this._id=r.pop(),t.data(s,this),this._container=t,this.data=[],this.fields=[],this._editingRow=null,this._sortField=null,this._sortOrder=l,this._firstDisplayingPage=1,this._init(e),this.render()}h.prototype={width:"auto",height:"auto",updateOnResize:!0,rowClass:c.noop,rowRenderer:null,rowClick:function(t){this.editing&&this.editItem(c(t.event.target).closest("tr"))},rowDoubleClick:c.noop,noDataContent:"Not found",noDataRowClass:"jsgrid-nodata-row",heading:!0,headerRowRenderer:null,headerRowClass:"jsgrid-header-row",headerCellClass:"jsgrid-header-cell",filtering:!1,filterRowRenderer:null,filterRowClass:"jsgrid-filter-row",inserting:!1,insertRowLocation:"bottom",insertRowRenderer:null,insertRowClass:"jsgrid-insert-row",editing:!1,editRowRenderer:null,editRowClass:"jsgrid-edit-row",confirmDeleting:!0,deleteConfirm:"Are you sure?",selecting:!0,selectedRowClass:"jsgrid-selected-row",oddRowClass:"jsgrid-row",evenRowClass:"jsgrid-alt-row",cellClass:"jsgrid-cell",sorting:!1,sortableClass:"jsgrid-header-sortable",sortAscClass:"jsgrid-header-sort jsgrid-header-sort-asc",sortDescClass:"jsgrid-header-sort jsgrid-header-sort-desc",paging:!1,pagerContainer:null,pageIndex:1,pageSize:20,pageButtonCount:15,pagerFormat:"Pages: {first} {prev} {pages} {next} {last} {pageIndex} of {pageCount}",pagePrevText:"Prev",pageNextText:"Next",pageFirstText:"First",pageLastText:"Last",pageNavigatorNextText:"...",pageNavigatorPrevText:"...",pagerContainerClass:"jsgrid-pager-container",pagerClass:"jsgrid-pager",pagerNavButtonClass:"jsgrid-pager-nav-button",pagerNavButtonInactiveClass:"jsgrid-pager-nav-inactive-button",pageClass:"jsgrid-pager-page",currentPageClass:"jsgrid-pager-current-page",customLoading:!1,pageLoading:!1,autoload:!1,controller:t,loadIndication:!0,loadIndicationDelay:500,loadMessage:"Please, wait...",loadShading:!0,invalidMessage:"Invalid data entered!",invalidNotify:function(t){t=c.map(t.errors,function(t){return t.message||null});e.alert([this.invalidMessage].concat(t).join("\n"))},onInit:c.noop,onRefreshing:c.noop,onRefreshed:c.noop,onPageChanged:c.noop,onItemDeleting:c.noop,onItemDeleted:c.noop,onItemInserting:c.noop,onItemInserted:c.noop,onItemEditing:c.noop,onItemEditCancelling:c.noop,onItemUpdating:c.noop,onItemUpdated:c.noop,onItemInvalid:c.noop,onDataLoading:c.noop,onDataLoaded:c.noop,onDataExporting:c.noop,onOptionChanging:c.noop,onOptionChanged:c.noop,onError:c.noop,invalidClass:"jsgrid-invalid",containerClass:"jsgrid",tableClass:"jsgrid-table",gridHeaderClass:"jsgrid-grid-header",gridBodyClass:"jsgrid-grid-body",_init:function(t){c.extend(this,t),this._initLoadStrategy(),this._initController(),this._initFields(),this._attachWindowLoadResize(),this._attachWindowResizeCallback(),this._callEventHandler(this.onInit)},loadStrategy:function(){return new(this.pageLoading?jsGrid.loadStrategies.PageLoadingStrategy:jsGrid.loadStrategies.DirectLoadingStrategy)(this)},_initLoadStrategy:function(){this._loadStrategy=a(this.loadStrategy,this)},_initController:function(){this._controller=c.extend({},t,a(this.controller,this))},renderTemplate:function(t,e,i){var n,r=[];for(n in i)r.push(i[n]);return r.unshift(t,e),(t=a.apply(null,r))===u||null===t?"":t},loadIndicator:function(t){return new jsGrid.LoadIndicator(t)},validation:function(t){return jsGrid.Validation&&new jsGrid.Validation(t)},_initFields:function(){var e=this;e.fields=c.map(e.fields,function(t){return(t=c.isPlainObject(t)?new(t.type&&jsGrid.fields[t.type]||jsGrid.Field)(t):t)._grid=e,t})},_attachWindowLoadResize:function(){c(e).on("load.table-"+this._id,c.proxy(this._refreshSize,this))},_attachWindowResizeCallback:function(){this.updateOnResize&&c(e).on("resize.table-"+this._id,c.proxy(this._refreshSize,this))},_detachWindowLoadResize:function(){c(e).off("load.table-"+this._id)},_detachWindowResizeCallback:function(){c(e).off("resize.table-"+this._id)},option:function(t,e){if(1===arguments.length)return this[t];t={option:t,oldValue:this[t],newValue:e},this._callEventHandler(this.onOptionChanging,t),this._handleOptionChange(t.option,t.newValue),this._callEventHandler(this.onOptionChanged,{option:t.option,value:t.newValue})},fieldOption:function(t,e,i){if(t=this._normalizeField(t),2===arguments.length)return t[e];t[e]=i,this._renderGrid()},_handleOptionChange:function(t,e){switch(this[t]=e,t){case"width":case"height":this._refreshSize();break;case"rowClass":case"rowRenderer":case"rowClick":case"rowDoubleClick":case"noDataRowClass":case"noDataContent":case"selecting":case"selectedRowClass":case"oddRowClass":case"evenRowClass":this._refreshContent();break;case"pageButtonCount":case"pagerFormat":case"pagePrevText":case"pageNextText":case"pageFirstText":case"pageLastText":case"pageNavigatorNextText":case"pageNavigatorPrevText":case"pagerClass":case"pagerNavButtonClass":case"pageClass":case"currentPageClass":case"pagerRenderer":this._refreshPager();break;case"fields":this._initFields(),this.render();break;case"data":case"editing":case"heading":case"filtering":case"inserting":case"paging":this.refresh();break;case"loadStrategy":case"pageLoading":this._initLoadStrategy(),this.search();break;case"pageIndex":this.openPage(e);break;case"pageSize":this.refresh(),this.search();break;case"editRowRenderer":case"editRowClass":this.cancelEdit();break;case"updateOnResize":this._detachWindowResizeCallback(),this._attachWindowResizeCallback();break;case"invalidNotify":case"invalidMessage":break;default:this.render()}},destroy:function(){this._detachWindowResizeCallback(),this._detachWindowLoadResize(),r.push(this._id),this._clear(),this._container.removeData(s)},render:function(){return this._renderGrid(),this.autoload?this.loadData():c.Deferred().resolve().promise()},_renderGrid:function(){this._clear(),this._container.addClass(this.containerClass).css("position","relative").append(this._createHeader()).append(this._createBody()),this._pagerContainer=this._createPagerContainer(),this._loadIndicator=this._createLoadIndicator(),this._validation=this._createValidation(),this.refresh()},_createLoadIndicator:function(){return a(this.loadIndicator,this,{message:this.loadMessage,shading:this.loadShading,container:this._container})},_createValidation:function(){return a(this.validation,this)},_clear:function(){this.cancelEdit(),clearTimeout(this._loadingTimer),this._pagerContainer&&this._pagerContainer.empty(),this._container.empty().css({position:"",width:"",height:""})},_createHeader:function(){var t=this._headerRow=this._createHeaderRow(),e=this._filterRow=this._createFilterRow(),i=this._insertRow=this._createInsertRow(),t=this._headerGrid=c("<table>").addClass(this.tableClass).append(t).append(e).append(i);return this._header=c("<div>").addClass(this.gridHeaderClass).addClass(this._scrollBarWidth()?"jsgrid-header-scrollbar":"").append(t)},_createBody:function(){var t=this._content=c("<tbody>"),t=this._bodyGrid=c("<table>").addClass(this.tableClass).append(t);return this._body=c("<div>").addClass(this.gridBodyClass).append(t).on("scroll",c.proxy(function(t){this._header.scrollLeft(t.target.scrollLeft)},this))},_createPagerContainer:function(){var t=this.pagerContainer||c("<div>").appendTo(this._container);return c(t).addClass(this.pagerContainerClass)},_eachField:function(i){var n=this;c.each(this.fields,function(t,e){e.visible&&i.call(n,e,t)})},_createHeaderRow:function(){var n;return c.isFunction(this.headerRowRenderer)?c(this.renderTemplate(this.headerRowRenderer,this)):(n=c("<tr>").addClass(this.headerRowClass),this._eachField(function(t,e){var i=this._prepareCell("<th>",t,"headercss",this.headerCellClass).append(this.renderTemplate(t.headerTemplate,t)).appendTo(n);this.sorting&&t.sorting&&i.addClass(this.sortableClass).on("click",c.proxy(function(){this.sort(e)},this))}),n)},_prepareCell:function(t,e,i,n){return c(t).css("width",e.width).addClass(n||this.cellClass).addClass(i&&e[i]||e.css).addClass(e.align?"jsgrid-align-"+e.align:"")},_createFilterRow:function(){var e;return c.isFunction(this.filterRowRenderer)?c(this.renderTemplate(this.filterRowRenderer,this)):(e=c("<tr>").addClass(this.filterRowClass),this._eachField(function(t){this._prepareCell("<td>",t,"filtercss").append(this.renderTemplate(t.filterTemplate,t)).appendTo(e)}),e)},_createInsertRow:function(){var e;return c.isFunction(this.insertRowRenderer)?c(this.renderTemplate(this.insertRowRenderer,this)):(e=c("<tr>").addClass(this.insertRowClass),this._eachField(function(t){this._prepareCell("<td>",t,"insertcss").append(this.renderTemplate(t.insertTemplate,t)).appendTo(e)}),e)},_callEventHandler:function(t,e){return t.call(this,c.extend(e,{grid:this})),e},reset:function(){return this._resetSorting(),this._resetPager(),this._loadStrategy.reset()},_resetPager:function(){this._firstDisplayingPage=1,this._setPage(1)},_resetSorting:function(){this._sortField=null,this._sortOrder=l,this._clearSortingCss()},refresh:function(){this._callEventHandler(this.onRefreshing),this.cancelEdit(),this._refreshHeading(),this._refreshFiltering(),this._refreshInserting(),this._refreshContent(),this._refreshPager(),this._refreshSize(),this._callEventHandler(this.onRefreshed)},_refreshHeading:function(){this._headerRow.toggle(this.heading)},_refreshFiltering:function(){this._filterRow.toggle(this.filtering)},_refreshInserting:function(){this._insertRow.toggle(this.inserting)},_refreshContent:function(){var t=this._content;if(t.empty(),!this.data.length)return t.append(this._createNoDataRow()),this;for(var e=this._loadStrategy.firstDisplayIndex(),i=this._loadStrategy.lastDisplayIndex(),n=e;n<i;n++){var r=this.data[n];t.append(this._createRow(r,n))}},_createNoDataRow:function(){var t=0;return this._eachField(function(){t++}),c("<tr>").addClass(this.noDataRowClass).append(c("<td>").addClass(this.cellClass).attr("colspan",t).append(this.renderTemplate(this.noDataContent,this)))},_createRow:function(e,i){var t;return c.isFunction(this.rowRenderer)?t=this.renderTemplate(this.rowRenderer,this,{item:e,itemIndex:i}):(t=c("<tr>"),this._renderCells(t,e)),t.addClass(this._getRowClasses(e,i)).data(o,e).on("click",c.proxy(function(t){this.rowClick({item:e,itemIndex:i,event:t})},this)).on("dblclick",c.proxy(function(t){this.rowDoubleClick({item:e,itemIndex:i,event:t})},this)),this.selecting&&this._attachRowHover(t),t},_getRowClasses:function(t,e){var i=[];return i.push((e+1)%2?this.oddRowClass:this.evenRowClass),i.push(a(this.rowClass,this,t,e)),i.join(" ")},_attachRowHover:function(t){var e=this.selectedRowClass;t.hover(function(){c(this).addClass(e)},function(){c(this).removeClass(e)})},_renderCells:function(e,i){return this._eachField(function(t){e.append(this._createCell(i,t))}),this},_createCell:function(t,e){var i=this._getItemFieldValue(t,e),t={value:i,item:t},i=c.isFunction(e.cellRenderer)?this.renderTemplate(e.cellRenderer,e,t):c("<td>").append(this.renderTemplate(e.itemTemplate||i,e,t));return this._prepareCell(i,e)},_getItemFieldValue:function(t,e){for(var i=e.name.split("."),n=t[i.shift()];n&&i.length;)n=n[i.shift()];return n},_setItemFieldValue:function(t,e,i){for(var n=e.name.split("."),r=t,a=n[0];r&&n.length;)r=(t=r)[a=n.shift()];if(!r)for(;n.length;)t=t[a]={},a=n.shift();t[a]=i},sort:function(t,e){return c.isPlainObject(t)&&(e=t.order,t=t.field),this._clearSortingCss(),this._setSortingParams(t,e),this._setSortingCss(),this._loadStrategy.sort()},_clearSortingCss:function(){this._headerRow.find("th").removeClass(this.sortAscClass).removeClass(this.sortDescClass)},_setSortingParams:function(t,e){t=this._normalizeField(t),e=e||(this._sortField===t?this._reversedSortOrder(this._sortOrder):l),this._sortField=t,this._sortOrder=e},_normalizeField:function(e){return c.isNumeric(e)?this.fields[e]:"string"==typeof e?c.grep(this.fields,function(t){return t.name===e})[0]:e},_reversedSortOrder:function(t){return t===l?"desc":l},_setSortingCss:function(){var t=this._visibleFieldIndex(this._sortField);this._headerRow.find("th").eq(t).addClass(this._sortOrder===l?this.sortAscClass:this.sortDescClass)},_visibleFieldIndex:function(t){return c.inArray(t,c.grep(this.fields,function(t){return t.visible}))},_sortData:function(){var i,n=this._sortFactor(),r=this._sortField;r&&(i=this).data.sort(function(t,e){t=i._getItemFieldValue(t,r),e=i._getItemFieldValue(e,r);return n*r.sortingFunc(t,e)})},_sortFactor:function(){return this._sortOrder===l?1:-1},_itemsCount:function(){return this._loadStrategy.itemsCount()},_pagesCount:function(){var t=this._itemsCount(),e=this.pageSize;return Math.floor(t/e)+(t%e?1:0)},_refreshPager:function(){var t=this._pagerContainer,e=(t.empty(),this.paging&&t.append(this._createPager()),this.paging&&1<this._pagesCount());t.toggle(e)},_createPager:function(){var t=c.isFunction(this.pagerRenderer)?c(this.pagerRenderer({pageIndex:this.pageIndex,pageCount:this._pagesCount()})):c("<div>").append(this._createPagerByFormat());return t.addClass(this.pagerClass),t},_createPagerByFormat:function(){var i=this.pageIndex,n=this._pagesCount(),r=this._itemsCount(),t=this.pagerFormat.split(" ");return c.map(t,c.proxy(function(t){var e=t;return"{pages}"===t?e=this._createPages():"{first}"===t?e=this._createPagerNavButton(this.pageFirstText,1,1<i):"{prev}"===t?e=this._createPagerNavButton(this.pagePrevText,i-1,1<i):"{next}"===t?e=this._createPagerNavButton(this.pageNextText,i+1,i<n):"{last}"===t?e=this._createPagerNavButton(this.pageLastText,n,i<n):"{pageIndex}"===t?e=i:"{pageCount}"===t?e=n:"{itemCount}"===t&&(e=r),c.isArray(e)?e.concat([" "]):[e," "]},this))},_createPages:function(){var t=this._pagesCount(),e=this.pageButtonCount,i=this._firstDisplayingPage,n=[];1<i&&n.push(this._createPagerPageNavButton(this.pageNavigatorPrevText,this.showPrevPages));for(var r=0,a=i;r<e&&a<=t;r++,a++)n.push(a===this.pageIndex?this._createPagerCurrentPage():this._createPagerPage(a));return i+e-1<t&&n.push(this._createPagerPageNavButton(this.pageNavigatorNextText,this.showNextPages)),n},_createPagerNavButton:function(t,e,i){return this._createPagerButton(t,this.pagerNavButtonClass+(i?"":" "+this.pagerNavButtonInactiveClass),i?function(){this.openPage(e)}:c.noop)},_createPagerPageNavButton:function(t,e){return this._createPagerButton(t,this.pagerNavButtonClass,e)},_createPagerPage:function(t){return this._createPagerButton(t,this.pageClass,function(){this.openPage(t)})},_createPagerButton:function(t,e,i){t=c("<a>").attr("href","javascript:void(0);").html(t).on("click",c.proxy(i,this));return c("<span>").addClass(e).append(t)},_createPagerCurrentPage:function(){return c("<span>").addClass(this.pageClass).addClass(this.currentPageClass).text(this.pageIndex)},_refreshSize:function(){this._refreshHeight(),this._refreshWidth()},_refreshWidth:function(){var t="auto"===this.width?this._getAutoWidth():this.width;this._container.width(t)},_getAutoWidth:function(){var t=this._headerGrid,e=this._header,i=(t.width("auto"),t.outerWidth()),e=e.outerWidth()-e.innerWidth();return t.width(""),i+e},_scrollBarWidth:function(){var t,e,i;return n===u&&((i=(t=c("<div></div>")).get(0)).style.width="50px",i.style.height="50px",i.style.position="absolute",i.style.top="-10000px",i.style.left="-10000px",(i=c("<div></div>")).get(0).style.height="100px",t.append(i).appendTo("body"),e=i.innerWidth(),t.get(0).style.overflowY="auto",i=i.innerWidth(),t.remove(),n=e-i),n},_refreshHeight:function(){var t,e=this._container,i=this._pagerContainer,n=this.height;e.height(n),"auto"!==n&&(n=e.height(),t=this._header.outerHeight(!0),i.parents(e).length&&(t+=i.outerHeight(!0)),this._body.outerHeight(n-t))},showPrevPages:function(){var t=this._firstDisplayingPage,e=this.pageButtonCount;this._firstDisplayingPage=e<t?t-e:1,this._refreshPager()},showNextPages:function(){var t=this._firstDisplayingPage,e=this.pageButtonCount,i=this._pagesCount();this._firstDisplayingPage=i<t+2*e?i-e+1:t+e,this._refreshPager()},openPage:function(t){t<1||t>this._pagesCount()||(this._setPage(t),this._loadStrategy.openPage(t))},_setPage:function(t){var e=this._firstDisplayingPage,i=this.pageButtonCount;(this.pageIndex=t)<e&&(this._firstDisplayingPage=t),e+i-1<t&&(this._firstDisplayingPage=t-i+1),this._callEventHandler(this.onPageChanged,{pageIndex:t})},_controllerCall:function(t,e,i,n){if(i)return c.Deferred().reject().promise();this._showLoading();var r,i=this._controller;if(i&&i[t])return i=i[t](e),r=c.Deferred(),i&&i.then?i.then(function(){r.resolve.apply(r,arguments)},function(){r.reject.apply(r,arguments)}):r.resolve(i),r.promise().done(c.proxy(n,this)).fail(c.proxy(this._errorHandler,this)).always(c.proxy(this._hideLoading,this));throw Error("controller has no method '"+t+"'")},_errorHandler:function(){this._callEventHandler(this.onError,{args:c.makeArray(arguments)})},_showLoading:function(){this.loadIndication&&(clearTimeout(this._loadingTimer),this._loadingTimer=setTimeout(c.proxy(function(){this._loadIndicator.show()},this),this.loadIndicationDelay))},_hideLoading:function(){this.loadIndication&&(clearTimeout(this._loadingTimer),this._loadIndicator.hide())},search:function(t){return this._resetSorting(),this._resetPager(),this.loadData(t)},loadData:function(t){t=t||(this.filtering?this.getFilter():{}),c.extend(t,this._loadStrategy.loadParams(),this._sortingParams());var e=this._callEventHandler(this.onDataLoading,{filter:t});return this._controllerCall("loadData",t,e.cancel,function(t){t&&(this._loadStrategy.finishLoad(t),this._callEventHandler(this.onDataLoaded,{data:t}))})},exportData:function(t){var t=t||{},e=t.type||"csv",i="";return this._callEventHandler(this.onDataExporting),i="csv"===e?this._dataToCsv(t):i},_dataToCsv:function(t){var e=!(t=t||{}).hasOwnProperty("includeHeaders")||t.includeHeaders,i=t.subset||"all",n=t.filter||u,r=[];if(e){for(var a=this.fields.length,s={},o=0;o<a;o++){var d=this.fields[o];"includeInDataExport"in d&&!0===d.includeInDataExport&&(s[o]=d.title||d.name)}e=this._itemToCsv(s,{},t);r.push(e)}for(var e=0,l=this.data.length,o=e="visible"===i?(l=this._firstDisplayingPage*this.pageSize)-this.pageSize:e;o<l;o++){var h=this.data[o],c=!0;(c=!n||n(h)?c:!1)&&(c=this._itemToCsv(h,this.fields,t),r.push(c))}return r.join("")},_itemToCsv:function(a,s,t){var e=(t=t||{}).delimiter||"|",o=!t.hasOwnProperty("encapsulate")||t.encapsulate,i=t.newline||"\r\n",d=t.transforms||{},s=s||{},l=this._getItemFieldValue,h=[];return Object.keys(a).forEach(function(t,e){var i="";if(0<s.length){var n,r=s[e];if("includeInDataExport"in r){if(!r.includeInDataExport)return;i="select"===r.type?(n=l(a,r),(c.grep(r.items,function(t,e){return t[r.valueField]===n})[0]||"")[r.textField]):l(a,r)}else i=l(a,r);d.hasOwnProperty(r.name)&&(i=d[r.name](i))}else i=a[t];h.push(i=o?'"'+i+'"':i)}),h.join(e)+i},getFilter:function(){var e={};return this._eachField(function(t){t.filtering&&this._setItemFieldValue(e,t,t.filterValue())}),e},_sortingParams:function(){return this.sorting&&this._sortField?{sortField:this._sortField.name,sortOrder:this._sortOrder}:{}},getSorting:function(){var t=this._sortingParams();return{field:t.sortField,order:t.sortOrder}},clearFilter:function(){var t=this._createFilterRow();return this._filterRow.replaceWith(t),this._filterRow=t,this.search()},insertItem:function(t){var e=t||this._getValidatedInsertItem();return e?(t=this._callEventHandler(this.onItemInserting,{item:e}),this._controllerCall("insertItem",e,t.cancel,function(t){this._loadStrategy.finishInsert(t=t||e,this.insertRowLocation),this._callEventHandler(this.onItemInserted,{item:t})})):c.Deferred().reject().promise()},_getValidatedInsertItem:function(){var t=this._getInsertItem();return this._validateItem(t,this._insertRow)?t:null},_getInsertItem:function(){var e={};return this._eachField(function(t){t.inserting&&this._setItemFieldValue(e,t,t.insertValue())}),e},_validateItem:function(i,n){var t,r=[],a={item:i,itemIndex:this._rowIndex(n),row:n};return this._eachField(function(e){var t;!e.validate||n===this._insertRow&&!e.inserting||n===this._getEditRow()&&!e.editing||(t=this._getItemFieldValue(i,e),t=this._validation.validate(c.extend({value:t,rules:e.validate},a)),this._setCellValidity(n.children().eq(this._visibleFieldIndex(e)),t),t.length&&r.push.apply(r,c.map(t,function(t){return{field:e,message:t}})))}),!r.length||(t=c.extend({errors:r},a),this._callEventHandler(this.onItemInvalid,t),this.invalidNotify(t),!1)},_setCellValidity:function(t,e){t.toggleClass(this.invalidClass,!!e.length).attr("title",e.join("\n"))},clearInsert:function(){var t=this._createInsertRow();this._insertRow.replaceWith(t),this._insertRow=t,this.refresh()},editItem:function(t){t=this.rowByItem(t);t.length&&this._editRow(t)},rowByItem:function(t){return t.jquery||t.nodeType?c(t):this._content.find("tr").filter(function(){return c.data(this,o)===t})},_editRow:function(t){var e;this.editing&&(e=t.data(o),this._callEventHandler(this.onItemEditing,{row:t,item:e,itemIndex:this._itemIndex(e)}).cancel||(this._editingRow&&this.cancelEdit(),e=this._createEditRow(e),(this._editingRow=t).hide(),e.insertBefore(t),t.data(i,e)))},_createEditRow:function(i){var n;return c.isFunction(this.editRowRenderer)?c(this.renderTemplate(this.editRowRenderer,this,{item:i,itemIndex:this._itemIndex(i)})):(n=c("<tr>").addClass(this.editRowClass),this._eachField(function(t){var e=this._getItemFieldValue(i,t);this._prepareCell("<td>",t,"editcss").append(this.renderTemplate(t.editTemplate||"",t,{value:e,item:i})).appendTo(n)}),n)},updateItem:function(t,e){1===arguments.length&&(e=t);t=t?this.rowByItem(t):this._editingRow;if(e=e||this._getValidatedEditedItem())return this._updateRow(t,e)},_getValidatedEditedItem:function(){var t=this._getEditedItem();return this._validateItem(t,this._getEditRow())?t:null},_updateRow:function(i,t){var n=i.data(o),r=this._itemIndex(n),a=c.extend(!0,{},n,t),t=this._callEventHandler(this.onItemUpdating,{row:i,item:a,itemIndex:r,previousItem:n});return this._controllerCall("updateItem",a,t.cancel,function(t){var e=c.extend(!0,{},n),t=(a=t||c.extend(!0,n,a),this._finishUpdate(i,a,r));this._callEventHandler(this.onItemUpdated,{row:t,item:a,itemIndex:r,previousItem:e})})},_rowIndex:function(t){return this._content.children().index(c(t))},_itemIndex:function(t){return c.inArray(t,this.data)},_finishUpdate:function(t,e,i){this.cancelEdit(),this.data[i]=e;e=this._createRow(e,i);return t.replaceWith(e),e},_getEditedItem:function(){var e={};return this._eachField(function(t){t.editing&&this._setItemFieldValue(e,t,t.editValue())}),e},cancelEdit:function(){var t,e,i;this._editingRow&&(e=(t=this._editingRow).data(o),i=this._itemIndex(e),this._callEventHandler(this.onItemEditCancelling,{row:t,item:e,itemIndex:i}),this._getEditRow().remove(),this._editingRow.show(),this._editingRow=null)},_getEditRow:function(){return this._editingRow&&this._editingRow.data(i)},deleteItem:function(t){t=this.rowByItem(t);if(t.length&&(!this.confirmDeleting||e.confirm(a(this.deleteConfirm,this,t.data(o)))))return this._deleteRow(t)},_deleteRow:function(t){var e=t.data(o),i=this._itemIndex(e),n=this._callEventHandler(this.onItemDeleting,{row:t,item:e,itemIndex:i});return this._controllerCall("deleteItem",e,n.cancel,function(){this._loadStrategy.finishDelete(e,i),this._callEventHandler(this.onItemDeleted,{row:t,item:e,itemIndex:i})})}},c.fn.jsGrid=function(n){var r=c.makeArray(arguments).slice(1),a=this;return this.each(function(){var t,e=c(this),i=e.data(s);if(i)if("string"==typeof n){if((t=i[n].apply(i,r))!==u&&t!==i)return a=t,!1}else i._detachWindowResizeCallback(),i._init(n),i.render();else new h(e,n)}),a};var g={},p={},_=function(i,t){c.each(t,function(t,e){c.isPlainObject(e)?_(i[t]||i[t[0].toUpperCase()+t.slice(1)],e):i.hasOwnProperty(t)?i[t]=e:i.prototype[t]=e})};e.jsGrid={Grid:h,fields:g,setDefaults:function(t){var e;c.isPlainObject(t)?e=h.prototype:(e=g[t].prototype,t=arguments[1]||{}),c.extend(e,t)},locales:p,locale:function(t){var e=c.isPlainObject(t)?t:p[t];if(!e)throw Error("unknown locale "+t);_(jsGrid,e)},version:"2.0.0"}})(window,jQuery),((t,e)=>{function i(t){this._init(t)}i.prototype={container:"body",message:"Loading...",shading:!0,zIndex:1e3,shaderClass:"jsgrid-load-shader",loadPanelClass:"jsgrid-load-panel",_init:function(t){e.extend(!0,this,t),this._initContainer(),this._initShader(),this._initLoadPanel()},_initContainer:function(){this._container=e(this.container)},_initShader:function(){this.shading&&(this._shader=e("<div>").addClass(this.shaderClass).hide().css({position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:this.zIndex}).appendTo(this._container))},_initLoadPanel:function(){this._loadPanel=e("<div>").addClass(this.loadPanelClass).text(this.message).hide().css({position:"absolute",top:"50%",left:"50%",zIndex:this.zIndex}).appendTo(this._container)},show:function(){var t=this._loadPanel.show(),e=t.outerWidth(),i=t.outerHeight();t.css({marginTop:-i/2,marginLeft:-e/2}),this._shader.show()},hide:function(){this._loadPanel.hide(),this._shader.hide()}},t.LoadIndicator=i})(jsGrid,jQuery),((t,e)=>{function i(t){this._grid=t}function n(t){this._grid=t,this._itemsCount=0}i.prototype={firstDisplayIndex:function(){var t=this._grid;return t.option("paging")?(t.option("pageIndex")-1)*t.option("pageSize"):0},lastDisplayIndex:function(){var t=this._grid,e=t.option("data").length;return t.option("paging")?Math.min(t.option("pageIndex")*t.option("pageSize"),e):e},itemsCount:function(){return this._grid.option("data").length},openPage:function(t){this._grid.refresh()},loadParams:function(){return{}},sort:function(){return this._grid._sortData(),this._grid.refresh(),e.Deferred().resolve().promise()},reset:function(){return this._grid.refresh(),e.Deferred().resolve().promise()},finishLoad:function(t){this._grid.option("data",t)},finishInsert:function(t,e){var i=this._grid;"top"===e?i.option("data").unshift(t):i.option("data").push(t),i.refresh()},finishDelete:function(t,e){var i=this._grid;i.option("data").splice(e,1),i.reset()}},n.prototype={firstDisplayIndex:function(){return 0},lastDisplayIndex:function(){return this._grid.option("data").length},itemsCount:function(){return this._itemsCount},openPage:function(t){this._grid.loadData()},loadParams:function(){var t=this._grid;return{pageIndex:t.option("pageIndex"),pageSize:t.option("pageSize")}},reset:function(){return this._grid.loadData()},sort:function(){return this._grid.loadData()},finishLoad:function(t){this._itemsCount=t.itemsCount,this._grid.option("data",t.data)},finishInsert:function(t){this._grid.search()},finishDelete:function(t,e){this._grid.search()}},t.loadStrategies={DirectLoadingStrategy:i,PageLoadingStrategy:n}})(jsGrid,jQuery),(t=>{function i(t){return null!=t}t.sortStrategies={string:function(t,e){return i(t)||i(e)?i(t)?i(e)?(""+t).localeCompare(""+e):1:-1:0},stringNaturalSort:function(t,e){return i(t)||i(e)?i(t)?i(e)?(""+t).localeCompare(""+e,void 0,{numeric:!0,sensitivity:"base"}):1:-1:0},number:function(t,e){return t-e},date:function(t,e){return t-e},numberAsString:function(t,e){return parseFloat(t)-parseFloat(e)}}})(jsGrid,jQuery),((t,r)=>{function e(t){this._init(t)}e.prototype={_init:function(t){r.extend(!0,this,t)},validate:function(i){var n=[];return r.each(this._normalizeRules(i.rules),function(t,e){e.validator(i.value,i.item,e.param)||(e=r.isFunction(e.message)?e.message(i.value,i.item):e.message,n.push(e))}),n},_normalizeRules:function(t){return r.isArray(t)||(t=[t]),r.map(t,r.proxy(function(t){return this._normalizeRule(t)},this))},_normalizeRule:function(t){if(r.isFunction(t="string"==typeof t?{validator:t}:t)&&(t={validator:t}),r.isPlainObject(t))return t=r.extend({},t),r.isFunction(t.validator)?t:this._applyNamedValidator(t,t.validator);throw Error("wrong validation config specified")},_applyNamedValidator:function(t,e){delete t.validator;var i=n[e];if(i)return r.isFunction(i)&&(i={validator:i}),r.extend({},i,t);throw Error('unknown validator "'+e+'"')}},t.Validation=e;var n={required:{message:"Field is required",validator:function(t){return null!=t&&""!==t}},rangeLength:{message:"Field value length is out of the defined range",validator:function(t,e,i){return t.length>=i[0]&&t.length<=i[1]}},minLength:{message:"Field value is too short",validator:function(t,e,i){return t.length>=i}},maxLength:{message:"Field value is too long",validator:function(t,e,i){return t.length<=i}},pattern:{message:"Field value is not matching the defined pattern",validator:function(t,e,i){return(i="string"==typeof i?new RegExp("^(?:"+i+")$"):i).test(t)}},range:{message:"Field value is out of the defined range",validator:function(t,e,i){return t>=i[0]&&t<=i[1]}},min:{message:"Field value is too small",validator:function(t,e,i){return i<=t}},max:{message:"Field value is too large",validator:function(t,e,i){return t<=i}}};t.validators=n})(jsGrid,jQuery),((e,i)=>{function t(t){i.extend(!0,this,t),this.sortingFunc=this._getSortingFunc()}t.prototype={name:"",title:null,css:"",align:"",width:100,visible:!0,filtering:!0,inserting:!0,editing:!0,sorting:!0,sorter:"string",includeInDataExport:!0,headerTemplate:function(){return null==this.title?this.name:this.title},itemTemplate:function(t,e){return t},filterTemplate:function(){return""},insertTemplate:function(){return""},editTemplate:function(t,e){return this._value=t,this.itemTemplate(t,e)},filterValue:function(){return""},insertValue:function(){return""},editValue:function(){return this._value},_getSortingFunc:function(){var t=this.sorter;if(i.isFunction(t))return t;if("string"==typeof t)return e.sortStrategies[t];throw Error('wrong sorter for the field "'+this.name+'"!')}},e.Field=t})(jsGrid,jQuery);
|
|
6
|
+
((e,c,u)=>{function a(t,e){return c.isFunction(t)?t.apply(e,c.makeArray(arguments).slice(2)):t}var n,s="JSGrid",o="JSGridItem",i="JSGridEditRow",r=[],d=0,l="asc",t={loadData:c.noop,insertItem:c.noop,updateItem:c.noop,deleteItem:c.noop};function h(t,e){t=c(t);0==r.length?(this._id=d,d++):this._id=r.pop(),t.data(s,this),this._container=t,this.data=[],this.fields=[],this._editingRow=null,this._sortField=null,this._sortOrder=l,this._firstDisplayingPage=1,this._init(e),this.render()}h.prototype={width:"auto",height:"auto",updateOnResize:!0,rowClass:c.noop,rowRenderer:null,rowClick:function(t){this.editing&&this.editItem(c(t.event.target).closest("tr"))},rowDoubleClick:c.noop,noDataContent:"Not found",noDataRowClass:"jsgrid-nodata-row",heading:!0,headerRowRenderer:null,headerRowClass:"jsgrid-header-row",headerCellClass:"jsgrid-header-cell",filtering:!1,filterRowRenderer:null,filterRowClass:"jsgrid-filter-row",inserting:!1,insertRowLocation:"bottom",insertRowRenderer:null,insertRowClass:"jsgrid-insert-row",editing:!1,editRowRenderer:null,editRowClass:"jsgrid-edit-row",confirmDeleting:!0,deleteConfirm:"Are you sure?",selecting:!0,selectedRowClass:"jsgrid-selected-row",oddRowClass:"jsgrid-row",evenRowClass:"jsgrid-alt-row",cellClass:"jsgrid-cell",sorting:!1,sortableClass:"jsgrid-header-sortable",sortAscClass:"jsgrid-header-sort jsgrid-header-sort-asc",sortDescClass:"jsgrid-header-sort jsgrid-header-sort-desc",paging:!1,pagerContainer:null,pageIndex:1,pageSize:20,pageButtonCount:15,pagerFormat:"Pages: {first} {prev} {pages} {next} {last} {pageIndex} of {pageCount}",pagePrevText:"Prev",pageNextText:"Next",pageFirstText:"First",pageLastText:"Last",pageNavigatorNextText:"...",pageNavigatorPrevText:"...",pagerContainerClass:"jsgrid-pager-container",pagerClass:"jsgrid-pager",pagerNavButtonClass:"jsgrid-pager-nav-button",pagerNavButtonInactiveClass:"jsgrid-pager-nav-inactive-button",pageClass:"jsgrid-pager-page",currentPageClass:"jsgrid-pager-current-page",customLoading:!1,pageLoading:!1,autoload:!1,controller:t,loadIndication:!0,loadIndicationDelay:500,loadMessage:"Please, wait...",loadShading:!0,invalidMessage:"Invalid data entered!",invalidNotify:function(t){t=c.map(t.errors,function(t){return t.message||null});e.alert([this.invalidMessage].concat(t).join("\n"))},onInit:c.noop,onRefreshing:c.noop,onRefreshed:c.noop,onPageChanged:c.noop,onItemDeleting:c.noop,onItemDeleted:c.noop,onItemInserting:c.noop,onItemInserted:c.noop,onItemEditing:c.noop,onItemEditCancelling:c.noop,onItemUpdating:c.noop,onItemUpdated:c.noop,onItemInvalid:c.noop,onDataLoading:c.noop,onDataLoaded:c.noop,onDataExporting:c.noop,onOptionChanging:c.noop,onOptionChanged:c.noop,onError:c.noop,invalidClass:"jsgrid-invalid",containerClass:"jsgrid",tableClass:"jsgrid-table",gridHeaderClass:"jsgrid-grid-header",gridBodyClass:"jsgrid-grid-body",_init:function(t){c.extend(this,t),this._initLoadStrategy(),this._initController(),this._initFields(),this._attachWindowLoadResize(),this._attachWindowResizeCallback(),this._callEventHandler(this.onInit)},loadStrategy:function(){return new(this.pageLoading?jsGrid.loadStrategies.PageLoadingStrategy:jsGrid.loadStrategies.DirectLoadingStrategy)(this)},_initLoadStrategy:function(){this._loadStrategy=a(this.loadStrategy,this)},_initController:function(){this._controller=c.extend({},t,a(this.controller,this))},renderTemplate:function(t,e,i){var n,r=[];for(n in i)r.push(i[n]);return r.unshift(t,e),(t=a.apply(null,r))===u||null===t?"":t},loadIndicator:function(t){return new jsGrid.LoadIndicator(t)},validation:function(t){return jsGrid.Validation&&new jsGrid.Validation(t)},_initFields:function(){var e=this;e.fields=c.map(e.fields,function(t){return(t=c.isPlainObject(t)?new(t.type&&jsGrid.fields[t.type]||jsGrid.Field)(t):t)._grid=e,t})},_attachWindowLoadResize:function(){c(e).on("load.table-"+this._id,c.proxy(this._refreshSize,this))},_attachWindowResizeCallback:function(){this.updateOnResize&&c(e).on("resize.table-"+this._id,c.proxy(this._refreshSize,this))},_detachWindowLoadResize:function(){c(e).off("load.table-"+this._id)},_detachWindowResizeCallback:function(){c(e).off("resize.table-"+this._id)},option:function(t,e){if(1===arguments.length)return this[t];t={option:t,oldValue:this[t],newValue:e},this._callEventHandler(this.onOptionChanging,t),this._handleOptionChange(t.option,t.newValue),this._callEventHandler(this.onOptionChanged,{option:t.option,value:t.newValue})},fieldOption:function(t,e,i){if(t=this._normalizeField(t),2===arguments.length)return t[e];t[e]=i,this._renderGrid()},_handleOptionChange:function(t,e){switch(this[t]=e,t){case"width":case"height":this._refreshSize();break;case"rowClass":case"rowRenderer":case"rowClick":case"rowDoubleClick":case"noDataRowClass":case"noDataContent":case"selecting":case"selectedRowClass":case"oddRowClass":case"evenRowClass":this._refreshContent();break;case"pageButtonCount":case"pagerFormat":case"pagePrevText":case"pageNextText":case"pageFirstText":case"pageLastText":case"pageNavigatorNextText":case"pageNavigatorPrevText":case"pagerClass":case"pagerNavButtonClass":case"pageClass":case"currentPageClass":case"pagerRenderer":this._refreshPager();break;case"fields":this._initFields(),this.render();break;case"data":case"editing":case"heading":case"filtering":case"inserting":case"paging":this.refresh();break;case"loadStrategy":case"pageLoading":this._initLoadStrategy(),this.search();break;case"pageIndex":this.openPage(e);break;case"pageSize":this.refresh(),this.search();break;case"editRowRenderer":case"editRowClass":this.cancelEdit();break;case"updateOnResize":this._detachWindowResizeCallback(),this._attachWindowResizeCallback();break;case"invalidNotify":case"invalidMessage":break;default:this.render()}},destroy:function(){this._detachWindowResizeCallback(),this._detachWindowLoadResize(),r.push(this._id),this._clear(),this._container.removeData(s)},render:function(){return this._renderGrid(),this.autoload?this.loadData():c.Deferred().resolve().promise()},_renderGrid:function(){this._clear(),this._container.addClass(this.containerClass).css("position","relative").append(this._createHeader()).append(this._createBody()),this._pagerContainer=this._createPagerContainer(),this._loadIndicator=this._createLoadIndicator(),this._validation=this._createValidation(),this.refresh()},_createLoadIndicator:function(){return a(this.loadIndicator,this,{message:this.loadMessage,shading:this.loadShading,container:this._container})},_createValidation:function(){return a(this.validation,this)},_clear:function(){this.cancelEdit(),clearTimeout(this._loadingTimer),this._pagerContainer&&this._pagerContainer.empty(),this._container.empty().css({position:"",width:"",height:""})},_createHeader:function(){var t=this._headerRow=this._createHeaderRow(),e=this._filterRow=this._createFilterRow(),i=this._insertRow=this._createInsertRow(),t=this._headerGrid=c("<table>").addClass(this.tableClass).append(t).append(e).append(i);return this._header=c("<div>").addClass(this.gridHeaderClass).addClass(this._scrollBarWidth()?"jsgrid-header-scrollbar":"").append(t)},_createBody:function(){var t=this._content=c("<tbody>"),t=this._bodyGrid=c("<table>").addClass(this.tableClass).append(t);return this._body=c("<div>").addClass(this.gridBodyClass).append(t).on("scroll",c.proxy(function(t){this._header.scrollLeft(t.target.scrollLeft)},this))},_createPagerContainer:function(){var t=this.pagerContainer||c("<div>").appendTo(this._container);return c(t).addClass(this.pagerContainerClass)},_eachField:function(i){var n=this;c.each(this.fields,function(t,e){e.visible&&i.call(n,e,t)})},_createHeaderRow:function(){var n;return c.isFunction(this.headerRowRenderer)?c(this.renderTemplate(this.headerRowRenderer,this)):(n=c("<tr>").addClass(this.headerRowClass),this._eachField(function(t,e){var i=this._prepareCell("<th>",t,"headercss",this.headerCellClass).append(this.renderTemplate(t.headerTemplate,t)).appendTo(n);this.sorting&&t.sorting&&i.addClass(this.sortableClass).on("click",c.proxy(function(){this.sort(e)},this))}),n)},_prepareCell:function(t,e,i,n){return c(t).css("width",e.width).addClass(n||this.cellClass).addClass(i&&e[i]||e.css).addClass(e.align?"jsgrid-align-"+e.align:"")},_createFilterRow:function(){var e;return c.isFunction(this.filterRowRenderer)?c(this.renderTemplate(this.filterRowRenderer,this)):(e=c("<tr>").addClass(this.filterRowClass),this._eachField(function(t){this._prepareCell("<td>",t,"filtercss").append(this.renderTemplate(t.filterTemplate,t)).appendTo(e)}),e)},_createInsertRow:function(){var e;return c.isFunction(this.insertRowRenderer)?c(this.renderTemplate(this.insertRowRenderer,this)):(e=c("<tr>").addClass(this.insertRowClass),this._eachField(function(t){this._prepareCell("<td>",t,"insertcss").append(this.renderTemplate(t.insertTemplate,t)).appendTo(e)}),e)},_callEventHandler:function(t,e){return t.call(this,c.extend(e,{grid:this})),e},reset:function(){return this._resetSorting(),this._resetPager(),this._loadStrategy.reset()},_resetPager:function(){this._firstDisplayingPage=1,this._setPage(1)},_resetSorting:function(){this._sortField=null,this._sortOrder=l,this._clearSortingCss()},refresh:function(){this._callEventHandler(this.onRefreshing),this.cancelEdit(),this._refreshHeading(),this._refreshFiltering(),this._refreshInserting(),this._refreshContent(),this._refreshPager(),this._refreshSize(),this._callEventHandler(this.onRefreshed)},_refreshHeading:function(){this._headerRow.toggle(this.heading)},_refreshFiltering:function(){this._filterRow.toggle(this.filtering)},_refreshInserting:function(){this._insertRow.toggle(this.inserting)},_refreshContent:function(){var t=this._content;if(t.empty(),!this.data.length)return t.append(this._createNoDataRow()),this;for(var e=this._loadStrategy.firstDisplayIndex(),i=this._loadStrategy.lastDisplayIndex(),n=e;n<i;n++){var r=this.data[n];t.append(this._createRow(r,n))}},_createNoDataRow:function(){var t=0;return this._eachField(function(){t++}),c("<tr>").addClass(this.noDataRowClass).append(c("<td>").addClass(this.cellClass).attr("colspan",t).append(this.renderTemplate(this.noDataContent,this)))},_createRow:function(e,i){var t;return c.isFunction(this.rowRenderer)?t=this.renderTemplate(this.rowRenderer,this,{item:e,itemIndex:i}):(t=c("<tr>"),this._renderCells(t,e)),t.addClass(this._getRowClasses(e,i)).data(o,e).on("click",c.proxy(function(t){this.rowClick({item:e,itemIndex:i,event:t})},this)).on("dblclick",c.proxy(function(t){this.rowDoubleClick({item:e,itemIndex:i,event:t})},this)),this.selecting&&this._attachRowHover(t),t},_getRowClasses:function(t,e){var i=[];return i.push((e+1)%2?this.oddRowClass:this.evenRowClass),i.push(a(this.rowClass,this,t,e)),i.join(" ")},_attachRowHover:function(t){var e=this.selectedRowClass;t.hover(function(){c(this).addClass(e)},function(){c(this).removeClass(e)})},_renderCells:function(e,i){return this._eachField(function(t){e.append(this._createCell(i,t))}),this},_createCell:function(t,e){var i=this._getItemFieldValue(t,e),t={value:i,item:t},i=c.isFunction(e.cellRenderer)?this.renderTemplate(e.cellRenderer,e,t):c("<td>").append(this.renderTemplate(e.itemTemplate||i,e,t));return this._prepareCell(i,e)},_getItemFieldValue:function(t,e){for(var i=e.name.split("."),n=t[i.shift()];n&&i.length;)n=n[i.shift()];return n},_setItemFieldValue:function(t,e,i){for(var n=e.name.split("."),r=t,a=n[0];r&&n.length;)r=(t=r)[a=n.shift()];if(!r)for(;n.length;)t=t[a]={},a=n.shift();t[a]=i},sort:function(t,e){return c.isPlainObject(t)&&(e=t.order,t=t.field),this._clearSortingCss(),this._setSortingParams(t,e),this._setSortingCss(),this._loadStrategy.sort()},_clearSortingCss:function(){this._headerRow.find("th").removeClass(this.sortAscClass).removeClass(this.sortDescClass)},_setSortingParams:function(t,e){t=this._normalizeField(t),e=e||(this._sortField===t?this._reversedSortOrder(this._sortOrder):l),this._sortField=t,this._sortOrder=e},_normalizeField:function(e){return c.isNumeric(e)?this.fields[e]:"string"==typeof e?c.grep(this.fields,function(t){return t.name===e})[0]:e},_reversedSortOrder:function(t){return t===l?"desc":l},_setSortingCss:function(){var t=this._visibleFieldIndex(this._sortField);this._headerRow.find("th").eq(t).addClass(this._sortOrder===l?this.sortAscClass:this.sortDescClass)},_visibleFieldIndex:function(t){return c.inArray(t,c.grep(this.fields,function(t){return t.visible}))},_sortData:function(){var i,n=this._sortFactor(),r=this._sortField;r&&(i=this).data.sort(function(t,e){t=i._getItemFieldValue(t,r),e=i._getItemFieldValue(e,r);return n*r.sortingFunc(t,e)})},_sortFactor:function(){return this._sortOrder===l?1:-1},_itemsCount:function(){return this._loadStrategy.itemsCount()},_pagesCount:function(){var t=this._itemsCount(),e=this.pageSize;return Math.floor(t/e)+(t%e?1:0)},_refreshPager:function(){var t=this._pagerContainer,e=(t.empty(),this.paging&&t.append(this._createPager()),this.paging&&1<this._pagesCount());t.toggle(e)},_createPager:function(){var t=c.isFunction(this.pagerRenderer)?c(this.pagerRenderer({pageIndex:this.pageIndex,pageCount:this._pagesCount()})):c("<div>").append(this._createPagerByFormat());return t.addClass(this.pagerClass),t},_createPagerByFormat:function(){var i=this.pageIndex,n=this._pagesCount(),r=this._itemsCount(),t=this.pagerFormat.split(" ");return c.map(t,c.proxy(function(t){var e=t;return"{pages}"===t?e=this._createPages():"{first}"===t?e=this._createPagerNavButton(this.pageFirstText,1,1<i):"{prev}"===t?e=this._createPagerNavButton(this.pagePrevText,i-1,1<i):"{next}"===t?e=this._createPagerNavButton(this.pageNextText,i+1,i<n):"{last}"===t?e=this._createPagerNavButton(this.pageLastText,n,i<n):"{pageIndex}"===t?e=i:"{pageCount}"===t?e=n:"{itemCount}"===t&&(e=r),c.isArray(e)?e.concat([" "]):[e," "]},this))},_createPages:function(){var t=this._pagesCount(),e=this.pageButtonCount,i=this._firstDisplayingPage,n=[];1<i&&n.push(this._createPagerPageNavButton(this.pageNavigatorPrevText,this.showPrevPages));for(var r=0,a=i;r<e&&a<=t;r++,a++)n.push(a===this.pageIndex?this._createPagerCurrentPage():this._createPagerPage(a));return i+e-1<t&&n.push(this._createPagerPageNavButton(this.pageNavigatorNextText,this.showNextPages)),n},_createPagerNavButton:function(t,e,i){return this._createPagerButton(t,this.pagerNavButtonClass+(i?"":" "+this.pagerNavButtonInactiveClass),i?function(){this.openPage(e)}:c.noop)},_createPagerPageNavButton:function(t,e){return this._createPagerButton(t,this.pagerNavButtonClass,e)},_createPagerPage:function(t){return this._createPagerButton(t,this.pageClass,function(){this.openPage(t)})},_createPagerButton:function(t,e,i){t=c("<a>").attr("href","javascript:void(0);").html(t).on("click",c.proxy(i,this));return c("<span>").addClass(e).append(t)},_createPagerCurrentPage:function(){return c("<span>").addClass(this.pageClass).addClass(this.currentPageClass).text(this.pageIndex)},_refreshSize:function(){this._refreshHeight(),this._refreshWidth()},_refreshWidth:function(){var t="auto"===this.width?this._getAutoWidth():this.width;this._container.width(t)},_getAutoWidth:function(){var t=this._headerGrid,e=this._header,i=(t.width("auto"),t.outerWidth()),e=e.outerWidth()-e.innerWidth();return t.width(""),i+e},_scrollBarWidth:function(){var t,e,i;return n===u&&((i=(t=c("<div></div>")).get(0)).style.width="50px",i.style.height="50px",i.style.position="absolute",i.style.top="-10000px",i.style.left="-10000px",(i=c("<div></div>")).get(0).style.height="100px",t.append(i).appendTo("body"),e=i.innerWidth(),t.get(0).style.overflowY="auto",i=i.innerWidth(),t.remove(),n=e-i),n},_refreshHeight:function(){var t,e=this._container,i=this._pagerContainer,n=this.height;e.height(n),"auto"!==n&&(n=e.height(),t=this._header.outerHeight(!0),i.parents(e).length&&(t+=i.outerHeight(!0)),this._body.outerHeight(n-t))},showPrevPages:function(){var t=this._firstDisplayingPage,e=this.pageButtonCount;this._firstDisplayingPage=e<t?t-e:1,this._refreshPager()},showNextPages:function(){var t=this._firstDisplayingPage,e=this.pageButtonCount,i=this._pagesCount();this._firstDisplayingPage=i<t+2*e?i-e+1:t+e,this._refreshPager()},openPage:function(t){t<1||t>this._pagesCount()||(this._setPage(t),this._loadStrategy.openPage(t))},_setPage:function(t){var e=this._firstDisplayingPage,i=this.pageButtonCount;(this.pageIndex=t)<e&&(this._firstDisplayingPage=t),e+i-1<t&&(this._firstDisplayingPage=t-i+1),this._callEventHandler(this.onPageChanged,{pageIndex:t})},_controllerCall:function(t,e,i,n){if(i)return c.Deferred().reject().promise();this._showLoading();var r,i=this._controller;if(i&&i[t])return i=i[t](e),r=c.Deferred(),i&&i.then?i.then(function(){r.resolve.apply(r,arguments)},function(){r.reject.apply(r,arguments)}):r.resolve(i),r.promise().done(c.proxy(n,this)).fail(c.proxy(this._errorHandler,this)).always(c.proxy(this._hideLoading,this));throw Error("controller has no method '"+t+"'")},_errorHandler:function(){this._callEventHandler(this.onError,{args:c.makeArray(arguments)})},_showLoading:function(){this.loadIndication&&(clearTimeout(this._loadingTimer),this._loadingTimer=setTimeout(c.proxy(function(){this._loadIndicator.show()},this),this.loadIndicationDelay))},_hideLoading:function(){this.loadIndication&&(clearTimeout(this._loadingTimer),this._loadIndicator.hide())},search:function(t){return this._resetSorting(),this._resetPager(),this.loadData(t)},loadData:function(t){t=t||(this.filtering?this.getFilter():{}),c.extend(t,this._loadStrategy.loadParams(),this._sortingParams());var e=this._callEventHandler(this.onDataLoading,{filter:t});return this._controllerCall("loadData",t,e.cancel,function(t){t&&(this._loadStrategy.finishLoad(t),this._callEventHandler(this.onDataLoaded,{data:t}))})},exportData:function(t){var t=t||{},e=t.type||"csv",i="";return this._callEventHandler(this.onDataExporting),i="csv"===e?this._dataToCsv(t):i},_dataToCsv:function(t){var e=!(t=t||{}).hasOwnProperty("includeHeaders")||t.includeHeaders,i=t.subset||"all",n=t.filter||u,r=[];if(e){for(var a=this.fields.length,s={},o=0;o<a;o++){var d=this.fields[o];"includeInDataExport"in d&&!0===d.includeInDataExport&&(s[o]=d.title||d.name)}e=this._itemToCsv(s,{},t);r.push(e)}for(var e=0,l=this.data.length,o=e="visible"===i?(l=this._firstDisplayingPage*this.pageSize)-this.pageSize:e;o<l;o++){var h=this.data[o],c=!0;(c=!n||n(h)?c:!1)&&(c=this._itemToCsv(h,this.fields,t),r.push(c))}return r.join("")},_itemToCsv:function(a,s,t){var e=(t=t||{}).delimiter||"|",o=!t.hasOwnProperty("encapsulate")||t.encapsulate,i=t.newline||"\r\n",d=t.transforms||{},s=s||{},l=this._getItemFieldValue,h=[];return Object.keys(a).forEach(function(t,e){var i="";if(0<s.length){var n,r=s[e];if("includeInDataExport"in r){if(!r.includeInDataExport)return;i="select"===r.type?(n=l(a,r),(c.grep(r.items,function(t,e){return t[r.valueField]===n})[0]||"")[r.textField]):l(a,r)}else i=l(a,r);d.hasOwnProperty(r.name)&&(i=d[r.name](i))}else i=a[t];h.push(i=o?'"'+i+'"':i)}),h.join(e)+i},getFilter:function(){var e={};return this._eachField(function(t){t.filtering&&this._setItemFieldValue(e,t,t.filterValue())}),e},_sortingParams:function(){return this.sorting&&this._sortField?{sortField:this._sortField.name,sortOrder:this._sortOrder}:{}},getSorting:function(){var t=this._sortingParams();return{field:t.sortField,order:t.sortOrder}},clearFilter:function(){var t=this._createFilterRow();return this._filterRow.replaceWith(t),this._filterRow=t,this.search()},insertItem:function(t){var e=t||this._getValidatedInsertItem();return e?(t=this._callEventHandler(this.onItemInserting,{item:e}),this._controllerCall("insertItem",e,t.cancel,function(t){this._loadStrategy.finishInsert(t=t||e,this.insertRowLocation),this._callEventHandler(this.onItemInserted,{item:t})})):c.Deferred().reject().promise()},_getValidatedInsertItem:function(){var t=this._getInsertItem();return this._validateItem(t,this._insertRow)?t:null},_getInsertItem:function(){var e={};return this._eachField(function(t){t.inserting&&this._setItemFieldValue(e,t,t.insertValue())}),e},_validateItem:function(i,n){var t,r=[],a={item:i,itemIndex:this._rowIndex(n),row:n};return this._eachField(function(e){var t;!e.validate||n===this._insertRow&&!e.inserting||n===this._getEditRow()&&!e.editing||(t=this._getItemFieldValue(i,e),t=this._validation.validate(c.extend({value:t,rules:e.validate},a)),this._setCellValidity(n.children().eq(this._visibleFieldIndex(e)),t),t.length&&r.push.apply(r,c.map(t,function(t){return{field:e,message:t}})))}),!r.length||(t=c.extend({errors:r},a),this._callEventHandler(this.onItemInvalid,t),this.invalidNotify(t),!1)},_setCellValidity:function(t,e){t.toggleClass(this.invalidClass,!!e.length).attr("title",e.join("\n"))},clearInsert:function(){var t=this._createInsertRow();this._insertRow.replaceWith(t),this._insertRow=t,this.refresh()},editItem:function(t){t=this.rowByItem(t);t.length&&this._editRow(t)},rowByItem:function(t){return t.jquery||t.nodeType?c(t):this._content.find("tr").filter(function(){return c.data(this,o)===t})},_editRow:function(t){var e;this.editing&&(e=t.data(o),this._callEventHandler(this.onItemEditing,{row:t,item:e,itemIndex:this._itemIndex(e)}).cancel||(this._editingRow&&this.cancelEdit(),e=this._createEditRow(e),(this._editingRow=t).hide(),e.insertBefore(t),t.data(i,e)))},_createEditRow:function(i){var n;return c.isFunction(this.editRowRenderer)?c(this.renderTemplate(this.editRowRenderer,this,{item:i,itemIndex:this._itemIndex(i)})):(n=c("<tr>").addClass(this.editRowClass),this._eachField(function(t){var e=this._getItemFieldValue(i,t);this._prepareCell("<td>",t,"editcss").append(this.renderTemplate(t.editTemplate||"",t,{value:e,item:i})).appendTo(n)}),n)},updateItem:function(t,e){1===arguments.length&&(e=t);t=t?this.rowByItem(t):this._editingRow;if(e=e||this._getValidatedEditedItem())return this._updateRow(t,e)},_getValidatedEditedItem:function(){var t=this._getEditedItem();return this._validateItem(t,this._getEditRow())?t:null},_updateRow:function(i,t){var n=i.data(o),r=this._itemIndex(n),a=c.extend(!0,{},n,t),t=this._callEventHandler(this.onItemUpdating,{row:i,item:a,itemIndex:r,previousItem:n});return this._controllerCall("updateItem",a,t.cancel,function(t){var e=c.extend(!0,{},n),t=(a=t||c.extend(!0,n,a),this._finishUpdate(i,a,r));this._callEventHandler(this.onItemUpdated,{row:t,item:a,itemIndex:r,previousItem:e})})},_rowIndex:function(t){return this._content.children().index(c(t))},_itemIndex:function(t){return c.inArray(t,this.data)},_finishUpdate:function(t,e,i){this.cancelEdit(),this.data[i]=e;e=this._createRow(e,i);return t.replaceWith(e),e},_getEditedItem:function(){var e={};return this._eachField(function(t){t.editing&&this._setItemFieldValue(e,t,t.editValue())}),e},cancelEdit:function(){var t,e,i;this._editingRow&&(e=(t=this._editingRow).data(o),i=this._itemIndex(e),this._callEventHandler(this.onItemEditCancelling,{row:t,item:e,itemIndex:i}),this._getEditRow().remove(),this._editingRow.show(),this._editingRow=null)},_getEditRow:function(){return this._editingRow&&this._editingRow.data(i)},deleteItem:function(t){t=this.rowByItem(t);if(t.length&&(!this.confirmDeleting||e.confirm(a(this.deleteConfirm,this,t.data(o)))))return this._deleteRow(t)},_deleteRow:function(t){var e=t.data(o),i=this._itemIndex(e),n=this._callEventHandler(this.onItemDeleting,{row:t,item:e,itemIndex:i});return this._controllerCall("deleteItem",e,n.cancel,function(){this._loadStrategy.finishDelete(e,i),this._callEventHandler(this.onItemDeleted,{row:t,item:e,itemIndex:i})})}},c.fn.jsGrid=function(n){var r=c.makeArray(arguments).slice(1),a=this;return this.each(function(){var t,e=c(this),i=e.data(s);if(i)if("string"==typeof n){if((t=i[n].apply(i,r))!==u&&t!==i)return a=t,!1}else i._detachWindowResizeCallback(),i._init(n),i.render();else new h(e,n)}),a};var g={},p={},_=function(i,t){c.each(t,function(t,e){c.isPlainObject(e)?_(i[t]||i[t[0].toUpperCase()+t.slice(1)],e):i.hasOwnProperty(t)?i[t]=e:i.prototype[t]=e})};e.jsGrid={Grid:h,fields:g,setDefaults:function(t){var e;c.isPlainObject(t)?e=h.prototype:(e=g[t].prototype,t=arguments[1]||{}),c.extend(e,t)},locales:p,locale:function(t){var e=c.isPlainObject(t)?t:p[t];if(!e)throw Error("unknown locale "+t);_(jsGrid,e)},version:"2.1.0"}})(window,jQuery),((t,e)=>{function i(t){this._init(t)}i.prototype={container:"body",message:"Loading...",shading:!0,zIndex:1e3,shaderClass:"jsgrid-load-shader",loadPanelClass:"jsgrid-load-panel",_init:function(t){e.extend(!0,this,t),this._initContainer(),this._initShader(),this._initLoadPanel()},_initContainer:function(){this._container=e(this.container)},_initShader:function(){this.shading&&(this._shader=e("<div>").addClass(this.shaderClass).hide().css({position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:this.zIndex}).appendTo(this._container))},_initLoadPanel:function(){this._loadPanel=e("<div>").addClass(this.loadPanelClass).text(this.message).hide().css({position:"absolute",top:"50%",left:"50%",zIndex:this.zIndex}).appendTo(this._container)},show:function(){var t=this._loadPanel.show(),e=t.outerWidth(),i=t.outerHeight();t.css({marginTop:-i/2,marginLeft:-e/2}),this._shader.show()},hide:function(){this._loadPanel.hide(),this._shader.hide()}},t.LoadIndicator=i})(jsGrid,jQuery),((t,e)=>{function i(t){this._grid=t}function n(t){this._grid=t,this._itemsCount=0}i.prototype={firstDisplayIndex:function(){var t=this._grid;return t.option("paging")?(t.option("pageIndex")-1)*t.option("pageSize"):0},lastDisplayIndex:function(){var t=this._grid,e=t.option("data").length;return t.option("paging")?Math.min(t.option("pageIndex")*t.option("pageSize"),e):e},itemsCount:function(){return this._grid.option("data").length},openPage:function(t){this._grid.refresh()},loadParams:function(){return{}},sort:function(){return this._grid._sortData(),this._grid.refresh(),e.Deferred().resolve().promise()},reset:function(){return this._grid.refresh(),e.Deferred().resolve().promise()},finishLoad:function(t){this._grid.option("data",t)},finishInsert:function(t,e){var i=this._grid;"top"===e?i.option("data").unshift(t):i.option("data").push(t),i.refresh()},finishDelete:function(t,e){var i=this._grid;i.option("data").splice(e,1),i.reset()}},n.prototype={firstDisplayIndex:function(){return 0},lastDisplayIndex:function(){return this._grid.option("data").length},itemsCount:function(){return this._itemsCount},openPage:function(t){this._grid.loadData()},loadParams:function(){var t=this._grid;return{pageIndex:t.option("pageIndex"),pageSize:t.option("pageSize")}},reset:function(){return this._grid.loadData()},sort:function(){return this._grid.loadData()},finishLoad:function(t){this._itemsCount=t.itemsCount,this._grid.option("data",t.data)},finishInsert:function(t){this._grid.search()},finishDelete:function(t,e){this._grid.search()}},t.loadStrategies={DirectLoadingStrategy:i,PageLoadingStrategy:n}})(jsGrid,jQuery),(t=>{function i(t){return null!=t}t.sortStrategies={string:function(t,e){return i(t)||i(e)?i(t)?i(e)?(""+t).localeCompare(""+e):1:-1:0},stringNaturalSort:function(t,e){return i(t)||i(e)?i(t)?i(e)?(""+t).localeCompare(""+e,void 0,{numeric:!0,sensitivity:"base"}):1:-1:0},number:function(t,e){return t-e},date:function(t,e){return t-e},numberAsString:function(t,e){return parseFloat(t)-parseFloat(e)}}})(jsGrid,jQuery),((t,r)=>{function e(t){this._init(t)}e.prototype={_init:function(t){r.extend(!0,this,t)},validate:function(i){var n=[];return r.each(this._normalizeRules(i.rules),function(t,e){e.validator(i.value,i.item,e.param)||(e=r.isFunction(e.message)?e.message(i.value,i.item):e.message,n.push(e))}),n},_normalizeRules:function(t){return r.isArray(t)||(t=[t]),r.map(t,r.proxy(function(t){return this._normalizeRule(t)},this))},_normalizeRule:function(t){if(r.isFunction(t="string"==typeof t?{validator:t}:t)&&(t={validator:t}),r.isPlainObject(t))return t=r.extend({},t),r.isFunction(t.validator)?t:this._applyNamedValidator(t,t.validator);throw Error("wrong validation config specified")},_applyNamedValidator:function(t,e){delete t.validator;var i=n[e];if(i)return r.isFunction(i)&&(i={validator:i}),r.extend({},i,t);throw Error('unknown validator "'+e+'"')}},t.Validation=e;var n={required:{message:"Field is required",validator:function(t){return null!=t&&""!==t}},rangeLength:{message:"Field value length is out of the defined range",validator:function(t,e,i){return t.length>=i[0]&&t.length<=i[1]}},minLength:{message:"Field value is too short",validator:function(t,e,i){return t.length>=i}},maxLength:{message:"Field value is too long",validator:function(t,e,i){return t.length<=i}},pattern:{message:"Field value is not matching the defined pattern",validator:function(t,e,i){return(i="string"==typeof i?new RegExp("^(?:"+i+")$"):i).test(t)}},range:{message:"Field value is out of the defined range",validator:function(t,e,i){return t>=i[0]&&t<=i[1]}},min:{message:"Field value is too small",validator:function(t,e,i){return i<=t}},max:{message:"Field value is too large",validator:function(t,e,i){return t<=i}}};t.validators=n})(jsGrid,jQuery),((e,i)=>{function t(t){i.extend(!0,this,t),this.sortingFunc=this._getSortingFunc()}t.prototype={name:"",title:null,css:"",align:"",width:100,visible:!0,filtering:!0,inserting:!0,editing:!0,sorting:!0,sorter:"string",includeInDataExport:!0,headerTemplate:function(){return null==this.title?this.name:this.title},itemTemplate:function(t,e){return t},filterTemplate:function(){return""},insertTemplate:function(){return""},editTemplate:function(t,e){return this._value=t,this.itemTemplate(t,e)},filterValue:function(){return""},insertValue:function(){return""},editValue:function(){return this._value},_getSortingFunc:function(){var t=this.sorter;if(i.isFunction(t))return t;if("string"==typeof t)return e.sortStrategies[t];throw Error('wrong sorter for the field "'+this.name+'"!')}},e.Field=t})(jsGrid,jQuery);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsxgrid",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Lightweight data grid jQuery plugin, with a built-in extra field set (avatars, JSON editor, select, collapsible textarea, datetime picker, row selection). A maintained fork of jsGrid.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"grid",
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
(function(jsGrid, $, undefined) {
|
|
2
|
+
|
|
3
|
+
// Already standalone - the native control field extends jsGrid.Field
|
|
4
|
+
// directly, same as every X-field. X-branded purely for naming parity,
|
|
5
|
+
// so it can be used instead of "control" once the native fields bundle
|
|
6
|
+
// is dropped in favor of the X set.
|
|
7
|
+
|
|
8
|
+
var Field = jsGrid.Field;
|
|
9
|
+
|
|
10
|
+
function Xcontrol(config) {
|
|
11
|
+
Field.call(this, config);
|
|
12
|
+
this.includeInDataExport = false;
|
|
13
|
+
this._configInitialized = false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Xcontrol.prototype = new Field({
|
|
17
|
+
css: "jsgrid-control-field",
|
|
18
|
+
align: "center",
|
|
19
|
+
width: 50,
|
|
20
|
+
filtering: false,
|
|
21
|
+
inserting: false,
|
|
22
|
+
editing: false,
|
|
23
|
+
sorting: false,
|
|
24
|
+
|
|
25
|
+
buttonClass: "jsgrid-button",
|
|
26
|
+
modeButtonClass: "jsgrid-mode-button",
|
|
27
|
+
|
|
28
|
+
modeOnButtonClass: "jsgrid-mode-on-button",
|
|
29
|
+
searchModeButtonClass: "jsgrid-search-mode-button",
|
|
30
|
+
insertModeButtonClass: "jsgrid-insert-mode-button",
|
|
31
|
+
editButtonClass: "jsgrid-edit-button",
|
|
32
|
+
deleteButtonClass: "jsgrid-delete-button",
|
|
33
|
+
searchButtonClass: "jsgrid-search-button",
|
|
34
|
+
clearFilterButtonClass: "jsgrid-clear-filter-button",
|
|
35
|
+
insertButtonClass: "jsgrid-insert-button",
|
|
36
|
+
updateButtonClass: "jsgrid-update-button",
|
|
37
|
+
cancelEditButtonClass: "jsgrid-cancel-edit-button",
|
|
38
|
+
|
|
39
|
+
searchModeButtonTooltip: "Switch to searching",
|
|
40
|
+
insertModeButtonTooltip: "Switch to inserting",
|
|
41
|
+
editButtonTooltip: "Edit",
|
|
42
|
+
deleteButtonTooltip: "Delete",
|
|
43
|
+
searchButtonTooltip: "Search",
|
|
44
|
+
clearFilterButtonTooltip: "Clear filter",
|
|
45
|
+
insertButtonTooltip: "Insert",
|
|
46
|
+
updateButtonTooltip: "Update",
|
|
47
|
+
cancelEditButtonTooltip: "Cancel edit",
|
|
48
|
+
|
|
49
|
+
editButton: true,
|
|
50
|
+
deleteButton: true,
|
|
51
|
+
clearFilterButton: true,
|
|
52
|
+
modeSwitchButton: true,
|
|
53
|
+
|
|
54
|
+
_initConfig: function() {
|
|
55
|
+
this._hasFiltering = this._grid.filtering;
|
|
56
|
+
this._hasInserting = this._grid.inserting;
|
|
57
|
+
|
|
58
|
+
if(this._hasInserting && this.modeSwitchButton) {
|
|
59
|
+
this._grid.inserting = false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this._configInitialized = true;
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
headerTemplate: function() {
|
|
66
|
+
if(!this._configInitialized) {
|
|
67
|
+
this._initConfig();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var hasFiltering = this._hasFiltering;
|
|
71
|
+
var hasInserting = this._hasInserting;
|
|
72
|
+
|
|
73
|
+
if(!this.modeSwitchButton || (!hasFiltering && !hasInserting))
|
|
74
|
+
return "";
|
|
75
|
+
|
|
76
|
+
if(hasFiltering && !hasInserting)
|
|
77
|
+
return this._createFilterSwitchButton();
|
|
78
|
+
|
|
79
|
+
if(hasInserting && !hasFiltering)
|
|
80
|
+
return this._createInsertSwitchButton();
|
|
81
|
+
|
|
82
|
+
return this._createModeSwitchButton();
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
itemTemplate: function(value, item) {
|
|
86
|
+
var $result = $([]);
|
|
87
|
+
|
|
88
|
+
if(this.editButton) {
|
|
89
|
+
$result = $result.add(this._createEditButton(item));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if(this.deleteButton) {
|
|
93
|
+
$result = $result.add(this._createDeleteButton(item));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return $result;
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
filterTemplate: function() {
|
|
100
|
+
var $result = this._createSearchButton();
|
|
101
|
+
return this.clearFilterButton ? $result.add(this._createClearFilterButton()) : $result;
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
insertTemplate: function() {
|
|
105
|
+
return this._createInsertButton();
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
editTemplate: function() {
|
|
109
|
+
return this._createUpdateButton().add(this._createCancelEditButton());
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
_createFilterSwitchButton: function() {
|
|
113
|
+
return this._createOnOffSwitchButton("filtering", this.searchModeButtonClass, true);
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
_createInsertSwitchButton: function() {
|
|
117
|
+
return this._createOnOffSwitchButton("inserting", this.insertModeButtonClass, false);
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
_createOnOffSwitchButton: function(option, cssClass, isOnInitially) {
|
|
121
|
+
var isOn = isOnInitially;
|
|
122
|
+
|
|
123
|
+
var updateButtonState = $.proxy(function() {
|
|
124
|
+
$button.toggleClass(this.modeOnButtonClass, isOn);
|
|
125
|
+
}, this);
|
|
126
|
+
|
|
127
|
+
var $button = this._createGridButton(this.modeButtonClass + " " + cssClass, "", function(grid) {
|
|
128
|
+
isOn = !isOn;
|
|
129
|
+
grid.option(option, isOn);
|
|
130
|
+
updateButtonState();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
updateButtonState();
|
|
134
|
+
|
|
135
|
+
return $button;
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
_createModeSwitchButton: function() {
|
|
139
|
+
var isInserting = false;
|
|
140
|
+
|
|
141
|
+
var updateButtonState = $.proxy(function() {
|
|
142
|
+
$button.attr("title", isInserting ? this.searchModeButtonTooltip : this.insertModeButtonTooltip)
|
|
143
|
+
.toggleClass(this.insertModeButtonClass, !isInserting)
|
|
144
|
+
.toggleClass(this.searchModeButtonClass, isInserting);
|
|
145
|
+
}, this);
|
|
146
|
+
|
|
147
|
+
var $button = this._createGridButton(this.modeButtonClass, "", function(grid) {
|
|
148
|
+
isInserting = !isInserting;
|
|
149
|
+
grid.option("inserting", isInserting);
|
|
150
|
+
grid.option("filtering", !isInserting);
|
|
151
|
+
updateButtonState();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
updateButtonState();
|
|
155
|
+
|
|
156
|
+
return $button;
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
_createEditButton: function(item) {
|
|
160
|
+
return this._createGridButton(this.editButtonClass, this.editButtonTooltip, function(grid, e) {
|
|
161
|
+
grid.editItem(item);
|
|
162
|
+
e.stopPropagation();
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
_createDeleteButton: function(item) {
|
|
167
|
+
return this._createGridButton(this.deleteButtonClass, this.deleteButtonTooltip, function(grid, e) {
|
|
168
|
+
grid.deleteItem(item);
|
|
169
|
+
e.stopPropagation();
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
_createSearchButton: function() {
|
|
174
|
+
return this._createGridButton(this.searchButtonClass, this.searchButtonTooltip, function(grid) {
|
|
175
|
+
grid.search();
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
_createClearFilterButton: function() {
|
|
180
|
+
return this._createGridButton(this.clearFilterButtonClass, this.clearFilterButtonTooltip, function(grid) {
|
|
181
|
+
grid.clearFilter();
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
_createInsertButton: function() {
|
|
186
|
+
return this._createGridButton(this.insertButtonClass, this.insertButtonTooltip, function(grid) {
|
|
187
|
+
grid.insertItem().done(function() {
|
|
188
|
+
grid.clearInsert();
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
_createUpdateButton: function() {
|
|
194
|
+
return this._createGridButton(this.updateButtonClass, this.updateButtonTooltip, function(grid, e) {
|
|
195
|
+
grid.updateItem();
|
|
196
|
+
e.stopPropagation();
|
|
197
|
+
});
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
_createCancelEditButton: function() {
|
|
201
|
+
return this._createGridButton(this.cancelEditButtonClass, this.cancelEditButtonTooltip, function(grid, e) {
|
|
202
|
+
grid.cancelEdit();
|
|
203
|
+
e.stopPropagation();
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
_createGridButton: function(cls, tooltip, clickHandler) {
|
|
208
|
+
var grid = this._grid;
|
|
209
|
+
|
|
210
|
+
return $("<input>").addClass(this.buttonClass)
|
|
211
|
+
.addClass(cls)
|
|
212
|
+
.attr({
|
|
213
|
+
type: "button",
|
|
214
|
+
title: tooltip
|
|
215
|
+
})
|
|
216
|
+
.on("click", function(e) {
|
|
217
|
+
clickHandler(grid, e);
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
editValue: function() {
|
|
222
|
+
return "";
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
jsGrid.fields.Xcontrol = Xcontrol;
|
|
228
|
+
|
|
229
|
+
}(jsGrid, jQuery));
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
(function(jsGrid, $, undefined) {
|
|
2
|
+
|
|
3
|
+
// Standalone: does not extend jsGrid.NumberField or Xtext, only jsGrid.Field.
|
|
4
|
+
|
|
5
|
+
var Field = jsGrid.Field;
|
|
6
|
+
|
|
7
|
+
var Xnumber = function (config) {
|
|
8
|
+
Field.call(this, config);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
Xnumber.prototype = new Field({
|
|
12
|
+
sorter: "number",
|
|
13
|
+
align: "right",
|
|
14
|
+
autosearch: true,
|
|
15
|
+
readOnly: false,
|
|
16
|
+
defaultSelected: null,//value to preset the filter input with, applied once on first filter render then reset
|
|
17
|
+
|
|
18
|
+
filterTemplate: function () {
|
|
19
|
+
if (!this.filtering)
|
|
20
|
+
return "";
|
|
21
|
+
|
|
22
|
+
var grid = this._grid,
|
|
23
|
+
$result = this.filterControl = this._createTextBox();
|
|
24
|
+
|
|
25
|
+
if (this.autosearch) {
|
|
26
|
+
$result.on("keypress", function (e) {
|
|
27
|
+
if (e.which === 13) {
|
|
28
|
+
grid.search();
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (this.defaultSelected !== null) {
|
|
35
|
+
$result.val(this.defaultSelected);
|
|
36
|
+
this.defaultSelected = null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return $result;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
insertTemplate: function () {
|
|
43
|
+
if (!this.inserting)
|
|
44
|
+
return "";
|
|
45
|
+
|
|
46
|
+
return this.insertControl = this._createTextBox();
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
editTemplate: function (value) {
|
|
50
|
+
if (!this.editing)
|
|
51
|
+
return this.itemTemplate.apply(this, arguments);
|
|
52
|
+
|
|
53
|
+
var $result = this.editControl = this._createTextBox();
|
|
54
|
+
$result.val(value);
|
|
55
|
+
return $result;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
filterValue: function () {
|
|
59
|
+
return this.filterControl.val()
|
|
60
|
+
? parseInt(this.filterControl.val() || 0, 10)
|
|
61
|
+
: undefined;
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
insertValue: function () {
|
|
65
|
+
return this.insertControl.val()
|
|
66
|
+
? parseInt(this.insertControl.val() || 0, 10)
|
|
67
|
+
: undefined;
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
editValue: function () {
|
|
71
|
+
return this.editControl.val()
|
|
72
|
+
? parseInt(this.editControl.val() || 0, 10)
|
|
73
|
+
: undefined;
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
_createTextBox: function () {
|
|
77
|
+
return $("<input>").attr("type", "number")
|
|
78
|
+
.prop("readonly", !!this.readOnly);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
jsGrid.fields.Xnumber = Xnumber;
|
|
83
|
+
|
|
84
|
+
}(jsGrid, jQuery));
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
(function(jsGrid, $, undefined) {
|
|
2
|
+
|
|
3
|
+
// Standalone: does not extend jsGrid.TextField, only jsGrid.Field.
|
|
4
|
+
|
|
5
|
+
var Field = jsGrid.Field;
|
|
6
|
+
|
|
7
|
+
var Xtext = function (config) {
|
|
8
|
+
Field.call(this, config);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
Xtext.prototype = new Field({
|
|
12
|
+
autosearch: true,
|
|
13
|
+
readOnly: false,
|
|
14
|
+
defaultSelected: null,//value to preset the filter input with, applied once on first filter render then reset
|
|
15
|
+
|
|
16
|
+
filterTemplate: function () {
|
|
17
|
+
if (!this.filtering)
|
|
18
|
+
return "";
|
|
19
|
+
|
|
20
|
+
var grid = this._grid,
|
|
21
|
+
$result = this.filterControl = this._createTextBox();
|
|
22
|
+
|
|
23
|
+
if (this.autosearch) {
|
|
24
|
+
$result.on("keypress", function (e) {
|
|
25
|
+
if (e.which === 13) {
|
|
26
|
+
grid.search();
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (this.defaultSelected !== null) {
|
|
33
|
+
$result.val(this.defaultSelected);
|
|
34
|
+
this.defaultSelected = null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return $result;
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
insertTemplate: function () {
|
|
41
|
+
if (!this.inserting)
|
|
42
|
+
return "";
|
|
43
|
+
|
|
44
|
+
return this.insertControl = this._createTextBox();
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
editTemplate: function (value) {
|
|
48
|
+
if (!this.editing)
|
|
49
|
+
return this.itemTemplate.apply(this, arguments);
|
|
50
|
+
|
|
51
|
+
var $result = this.editControl = this._createTextBox();
|
|
52
|
+
$result.val(value);
|
|
53
|
+
return $result;
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
filterValue: function () {
|
|
57
|
+
return this.filterControl.val();
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
insertValue: function () {
|
|
61
|
+
return this.insertControl.val();
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
editValue: function () {
|
|
65
|
+
return this.editControl.val();
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
_createTextBox: function () {
|
|
69
|
+
return $("<input>").attr("type", "text")
|
|
70
|
+
.prop("readonly", !!this.readOnly);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
jsGrid.fields.Xtext = Xtext;
|
|
75
|
+
|
|
76
|
+
}(jsGrid, jQuery));
|