@componyx/ui 0.0.0-stage → 1.0.4
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/AppSkin/AppSkin.css +1268 -0
- package/AppSkin/AppSkin.js +2748 -0
- package/AppSkin/Themes/Default.css +241 -0
- package/Base/Base.js +3407 -0
- package/Base/ComponentIcons.css +66 -0
- package/Base/Font/ComponentIcons.woff +0 -0
- package/Base/Font/UI.woff +0 -0
- package/Base/Library.js +8432 -0
- package/Base/NavigationManager.js +462 -0
- package/Base/ResponsiveTemplates.js +371 -0
- package/Base/Sanitizer.js +288 -0
- package/Base/Themes/Default.css +255 -0
- package/Base/UI.css +618 -0
- package/Base/UIResourcePath.js +6 -0
- package/Bindary/Bindary.js +2011 -0
- package/Bindary/Modules/Connection.js +216 -0
- package/Bindary/Modules/Core.js +854 -0
- package/Bindary/Modules/DataUpdater.js +351 -0
- package/Bindary/Modules/ExpressionEngine.js +347 -0
- package/Bindary/Modules/ProxyManager.js +482 -0
- package/Bindary/Modules/Renderer.js +605 -0
- package/Bindary/Modules/Router.js +291 -0
- package/Bindary/Modules/Scroller.js +89 -0
- package/Bindary/Modules/Template.js +1273 -0
- package/BookmarkSpy/BookmarkSpy.js +430 -0
- package/Box/Box.css +36 -0
- package/Box/Box.js +1685 -0
- package/Button/Button.css +470 -0
- package/Button/Button.js +1398 -0
- package/Button/Themes/Default.css +200 -0
- package/Carousel/Carousel.css +273 -0
- package/Carousel/Carousel.js +607 -0
- package/ColorButton/ColorButton.css +39 -0
- package/ColorButton/ColorButton.js +336 -0
- package/ColorPicker/ColorPicker.css +359 -0
- package/ColorPicker/ColorPicker.js +972 -0
- package/ComboBox/ComboBox.css +357 -0
- package/ComboBox/ComboBox.js +2342 -0
- package/ComboBox/Themes/Default.css +23 -0
- package/DataPager/DataPager.css +72 -0
- package/DataPager/DataPager.js +674 -0
- package/DatePicker/DatePicker.css +227 -0
- package/DatePicker/DatePicker.js +1531 -0
- package/DatePicker/Themes/Default.css +26 -0
- package/Dialog/Dialog.css +106 -0
- package/Dialog/Dialog.js +572 -0
- package/Dialog/Themes/Default.css +10 -0
- package/Editor/Data/Emoji.json +8285 -0
- package/Editor/Data/Special.json +1042 -0
- package/Editor/Editor.css +1562 -0
- package/Editor/Editor.js +4058 -0
- package/Editor/Font/Editor.woff +0 -0
- package/Editor/Modules/ComponentFactory.js +565 -0
- package/Editor/Modules/ContentManager.js +748 -0
- package/Editor/Modules/DialogManager.js +1234 -0
- package/Editor/Modules/EventManager.js +458 -0
- package/Editor/Modules/Format.js +950 -0
- package/Editor/Modules/History.js +191 -0
- package/Editor/Modules/LayoutState.js +379 -0
- package/Editor/Modules/ListManager.js +296 -0
- package/Editor/Modules/MenuManager.js +388 -0
- package/Editor/Modules/NodeManager.js +681 -0
- package/Editor/Modules/ParagraphButtons.js +122 -0
- package/Editor/Modules/Resizer.js +176 -0
- package/Editor/Modules/SelectionRange.js +564 -0
- package/Editor/Modules/SourceViewBuilder.js +212 -0
- package/Editor/Modules/SymbolPicker.js +208 -0
- package/Editor/Modules/Table.js +2327 -0
- package/Editor/Modules/TableDialog.js +757 -0
- package/Editor/Modules/Toolbar.js +375 -0
- package/Editor/Modules/TooltipMenu.js +125 -0
- package/Editor/Modules/Utility.js +131 -0
- package/Editor/Themes/Default.css +204 -0
- package/FileUpload/FileUpload.css +156 -0
- package/FileUpload/FileUpload.js +898 -0
- package/FileUpload/Themes/Default.css +17 -0
- package/Form/Form.css +1934 -0
- package/Form/Form.js +4943 -0
- package/Form/Modules/ActionManager.js +368 -0
- package/Form/Modules/BuildPanelManager.js +319 -0
- package/Form/Modules/ComponentFactory.js +468 -0
- package/Form/Modules/ComponentPanel.js +265 -0
- package/Form/Modules/ConfigPanelManager.js +685 -0
- package/Form/Modules/DataBinder.js +602 -0
- package/Form/Modules/DataObserver.js +717 -0
- package/Form/Modules/Draggable.js +756 -0
- package/Form/Modules/OptionsPanel.js +342 -0
- package/Form/Modules/Renderer.js +1889 -0
- package/Form/Modules/RuleEngine.js +585 -0
- package/Form/Modules/RulesPanel.js +1158 -0
- package/Form/Modules/Types.js +1709 -0
- package/Form/Modules/ValidationManager.js +194 -0
- package/Form/Themes/Default.css +216 -0
- package/FormField/FormField.css +468 -0
- package/FormField/FormField.js +576 -0
- package/FormField/Themes/Default.css +99 -0
- package/Grid/Grid.css +544 -0
- package/Grid/Grid.js +3761 -0
- package/Grid/Themes/Default.css +43 -0
- package/LICENSE +126 -0
- package/MaskedTextBox/MaskedTextBox.css +28 -0
- package/MaskedTextBox/MaskedTextBox.js +642 -0
- package/MaskedTextBox/Themes/Default.css +6 -0
- package/Menu/Menu.css +328 -0
- package/Menu/Menu.js +2386 -0
- package/Menu/Themes/Default.css +24 -0
- package/NumericBox/NumericBox.css +120 -0
- package/NumericBox/NumericBox.js +984 -0
- package/PanelBar/PanelBar.css +123 -0
- package/PanelBar/PanelBar.js +505 -0
- package/PanelBar/Themes/Default.css +51 -0
- package/PieChart/PieChart.css +95 -0
- package/PieChart/PieChart.js +820 -0
- package/PieChart/Themes/Default.css +9 -0
- package/README.md +178 -3
- package/Slider/Slider.css +348 -0
- package/Slider/Slider.js +1306 -0
- package/Slider/Themes/Default.css +44 -0
- package/TabStrip/TabStrip.css +52 -0
- package/TabStrip/TabStrip.js +362 -0
- package/TabStrip/Themes/Default.css +35 -0
- package/TimePicker/Themes/Default.css +30 -0
- package/TimePicker/TimePicker.css +253 -0
- package/TimePicker/TimePicker.js +1485 -0
- package/TooltipManager/Themes/Default.css +21 -0
- package/TooltipManager/TooltipManager.css +227 -0
- package/TooltipManager/TooltipManager.js +791 -0
- package/Validator/Validator.css +54 -0
- package/Validator/Validator.js +2508 -0
- package/componyx.html-data.json +619 -0
- package/index.js +27 -0
- package/package.json +43 -4
- package/types/AppSkin.d.ts +842 -0
- package/types/Base.d.ts +1034 -0
- package/types/Bindary.d.ts +1196 -0
- package/types/BookmarkSpy.d.ts +112 -0
- package/types/Box.d.ts +374 -0
- package/types/Button.d.ts +455 -0
- package/types/Carousel.d.ts +136 -0
- package/types/ColorButton.d.ts +120 -0
- package/types/ColorPicker.d.ts +225 -0
- package/types/ComboBox.d.ts +507 -0
- package/types/DataPager.d.ts +152 -0
- package/types/DatePicker.d.ts +354 -0
- package/types/Dialog.d.ts +160 -0
- package/types/Editor.d.ts +1289 -0
- package/types/FileUpload.d.ts +206 -0
- package/types/Form.d.ts +3078 -0
- package/types/FormField.d.ts +204 -0
- package/types/Grid.d.ts +911 -0
- package/types/Library.d.ts +1899 -0
- package/types/MaskedTextBox.d.ts +91 -0
- package/types/Menu.d.ts +577 -0
- package/types/NumericBox.d.ts +310 -0
- package/types/PanelBar.d.ts +223 -0
- package/types/PieChart.d.ts +224 -0
- package/types/ResponsiveTemplates.d.ts +108 -0
- package/types/Slider.d.ts +227 -0
- package/types/TabStrip.d.ts +185 -0
- package/types/TimePicker.d.ts +265 -0
- package/types/TooltipManager.d.ts +178 -0
- package/types/UI.d.ts +29 -0
- package/types/Validator.d.ts +653 -0
- package/types/index.d.ts +59 -0
- package/ui.css +11783 -0
- package/ui.js +79477 -0
- package/ui.min.css +138 -0
- package/ui.min.js +264 -0
- package/ui.min.js.map +1 -0
package/Grid/Grid.js
ADDED
|
@@ -0,0 +1,3761 @@
|
|
|
1
|
+
/*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
|
|
2
|
+
import '../Base/Base.js';
|
|
3
|
+
import '../Base/Library.js';
|
|
4
|
+
import '../DataPager/DataPager.js';
|
|
5
|
+
import '../Box/Box.js';
|
|
6
|
+
import '../TooltipManager/TooltipManager.js';
|
|
7
|
+
import '../Button/Button.js';
|
|
8
|
+
import '../Menu/Menu.js';
|
|
9
|
+
import '../NumericBox/NumericBox.js';
|
|
10
|
+
import '../ComboBox/ComboBox.js';
|
|
11
|
+
import '../DatePicker/DatePicker.js';
|
|
12
|
+
import '../TimePicker/TimePicker.js';
|
|
13
|
+
import '../Slider/Slider.js';
|
|
14
|
+
|
|
15
|
+
(function (window)
|
|
16
|
+
{
|
|
17
|
+
/**
|
|
18
|
+
* Grid class.
|
|
19
|
+
* @class
|
|
20
|
+
* @memberof componyx.UI
|
|
21
|
+
* @augments componyx.UI.base.Component
|
|
22
|
+
* @mixes componyx.UI.base.methods
|
|
23
|
+
* @param {String} id The id of the component.
|
|
24
|
+
* @param {Object|HTMLElement} properties The properties used to initialize the component or the container element.
|
|
25
|
+
* @property {componyx.UI.base.AjaxMethod} ajax.load - AJAX method used to load the grid's items.
|
|
26
|
+
* @property {componyx.UI.base.AjaxMethod} ajax.loadItem - AJAX method used to load an item's detail data when a row is expanded.
|
|
27
|
+
* @returns {Object} An instance of the component.
|
|
28
|
+
*/
|
|
29
|
+
componyx.UI.Grid = function Grid(id, properties)
|
|
30
|
+
{
|
|
31
|
+
var _instance = this,
|
|
32
|
+
_elementHandler, _outsideClick = true,
|
|
33
|
+
_documentHandler = [];
|
|
34
|
+
$base.static.ThemeOption;
|
|
35
|
+
var _rowSelectionOption = componyx.UI.Grid.RowSelectionOption,
|
|
36
|
+
_rowExpansionOption = componyx.UI.Grid.RowExpansionOption,
|
|
37
|
+
_groupExpansionOption = componyx.UI.Grid.GroupExpansionOption,
|
|
38
|
+
_columnSortingOption = componyx.UI.Grid.ColumnSortingOption,
|
|
39
|
+
_sortOrderOption = componyx.UI.Grid.SortOrderOption,
|
|
40
|
+
_filterInputTypeOption = componyx.UI.Grid.FilterInputTypeOption,
|
|
41
|
+
_filterMenuOptions = componyx.UI.Grid.FilterMenuOptions,
|
|
42
|
+
_filterNumeric = _filterMenuOptions.EQUALTO + _filterMenuOptions.NOTEQUALTO + _filterMenuOptions.GREATERTHAN + _filterMenuOptions.GREATERTHANOREQUALTO + _filterMenuOptions.LESSTHAN + _filterMenuOptions.LESSTHANOREQUALTO + _filterMenuOptions.EMPTY + _filterMenuOptions.NOTEMPTY,
|
|
43
|
+
_filterText = _filterMenuOptions.EQUALTO + _filterMenuOptions.NOTEQUALTO + _filterMenuOptions.STARTSWITH + _filterMenuOptions.NOTSTARTSWITH + _filterMenuOptions.ENDSWITH + _filterMenuOptions.NOTENDSWITH + _filterMenuOptions.CONTAINS + _filterMenuOptions.NOTCONTAINS + _filterMenuOptions.EMPTY + _filterMenuOptions.NOTEMPTY,
|
|
44
|
+
_filterMenu, _filter = {}, _sort = {}, _headerDraggables = {}, _itemDraggables = [], _selectedItems = {}, _timerIds = [],
|
|
45
|
+
_fixedColumnStyleSheet, _lastScrollLeft = 0, _scrollTimerId, _fixedColumnUpdateTimerId,
|
|
46
|
+
_pager, _depthLevels, _loading, _ajax = [], _divHeader, _divFilter, _divContent, _tooltipManager, _scrollbarSize, _selectable, _hidden,
|
|
47
|
+
_divNoResult, _divPreloader, _lastItem, _expandedItemId, _itemDropZones,
|
|
48
|
+
_tableData = { header: null, filter: null, content: null, columnIndex: null, columnStartWidth: null, totalWidth: null, columnDistribution: null },
|
|
49
|
+
_treeGroup, _cancelSelect, _forceSelect = false, _hasGroups,
|
|
50
|
+
_displayRows = function (itemId, display)
|
|
51
|
+
{
|
|
52
|
+
var items = _treeGroup[itemId].items,
|
|
53
|
+
cssClass = _classOption.EXPANDED,
|
|
54
|
+
cssClassGroupHead = _instance.cssClassGroupHead || _classOption.GROUP_HEAD,
|
|
55
|
+
tr = getItemRow(itemId),
|
|
56
|
+
td = $lib(cssClassGroupHead, tr, 'td', true);
|
|
57
|
+
|
|
58
|
+
if (td)
|
|
59
|
+
{
|
|
60
|
+
if (display == null)
|
|
61
|
+
$lib.toggleClass(td, cssClass);
|
|
62
|
+
else if (display == '')
|
|
63
|
+
$lib.addClass(td, cssClass);
|
|
64
|
+
else
|
|
65
|
+
$lib.removeClass(td, cssClass);
|
|
66
|
+
|
|
67
|
+
if ($lib.hasClass(td, cssClass))
|
|
68
|
+
_instance.events.onItemGroupExpand.fire(_instance, eventArgs(loadItem(itemId), tr, td));
|
|
69
|
+
else
|
|
70
|
+
_instance.events.onItemGroupCollapse.fire(_instance, eventArgs(loadItem(itemId), tr, td));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for (var index = 0; index < items.length; ++index)
|
|
74
|
+
{
|
|
75
|
+
tr = getItemRow(items[index].id);
|
|
76
|
+
|
|
77
|
+
if (display == null)
|
|
78
|
+
tr.style.display = (tr.style.display == 'none') ? '' : 'none'; // toggle
|
|
79
|
+
else
|
|
80
|
+
tr.style.display = display; // set as specified
|
|
81
|
+
|
|
82
|
+
if (items[index].isGroup && tr.style.display == 'none') // always collapse children when parent is collapsed
|
|
83
|
+
displayRows(items[index].id, 'none');
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
_classOption =
|
|
87
|
+
{
|
|
88
|
+
HEADER: 'header',
|
|
89
|
+
CONTENT: 'content',
|
|
90
|
+
DATA_PAGER: 'data-pager',
|
|
91
|
+
RESIZABLE: 'resizable',
|
|
92
|
+
DRAGGABLE: 'draggable',
|
|
93
|
+
SELECTABLE: 'selectable',
|
|
94
|
+
DRAG: 'drag',
|
|
95
|
+
SCROLLABLE_X: 'scrollable-x',
|
|
96
|
+
SCROLLABLE_Y: 'scrollable-y',
|
|
97
|
+
TEXTBOX: 'textbox',
|
|
98
|
+
FILTERROW: 'filter',
|
|
99
|
+
FILTER_BUTTON: 'button filter',
|
|
100
|
+
FILTERMENU: 'menu filter',
|
|
101
|
+
FILTERRANGE: 'range',
|
|
102
|
+
FILTER_FROM: 'filter-from',
|
|
103
|
+
FILTER_TO: 'filter-to',
|
|
104
|
+
SORTASC: 'asc',
|
|
105
|
+
SORTDESC: 'desc',
|
|
106
|
+
HEADER_LABEL: 'header-label',
|
|
107
|
+
RESIZE_HANDLE: 'resize-handle',
|
|
108
|
+
COLUMN_SORTING: 'column-sorting',
|
|
109
|
+
DRAG_GHOST: 'drag-ghost',
|
|
110
|
+
DROPPABLE: 'droppable',
|
|
111
|
+
LEFT: 'left',
|
|
112
|
+
RIGHT: 'right',
|
|
113
|
+
TOP: 'top',
|
|
114
|
+
BOTTOM: 'bottom',
|
|
115
|
+
PRELOADER: 'preloader',
|
|
116
|
+
NORESULT: 'noresult',
|
|
117
|
+
CHECKBOX: 'checkbox',
|
|
118
|
+
EXPAND: 'expand',
|
|
119
|
+
EXPAND_ICON: 'expand-icon',
|
|
120
|
+
EXPANDED: 'expanded',
|
|
121
|
+
SELECTED: 'selected',
|
|
122
|
+
COLUMN_GROUP: 'column-group',
|
|
123
|
+
COLUMN: 'column',
|
|
124
|
+
FIXED_COLUMN: 'fixed-column',
|
|
125
|
+
HIDDEN_COLUMN: 'hidden-column',
|
|
126
|
+
ITEM: '',
|
|
127
|
+
GROUP_ITEM: 'group-item',
|
|
128
|
+
GROUP_HEAD: 'group-head'
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// define public properties
|
|
132
|
+
/**
|
|
133
|
+
* Gets or sets the css class of the header container.
|
|
134
|
+
* @type {String}
|
|
135
|
+
*/
|
|
136
|
+
this.cssClassHeader = '';
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Gets or sets the css class of the content container.
|
|
140
|
+
* @type {String}
|
|
141
|
+
*/
|
|
142
|
+
this.cssClassContent = '';
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Gets or sets the css class of the datapager.
|
|
146
|
+
* @type {String}
|
|
147
|
+
*/
|
|
148
|
+
this.cssClassDataPager = '';
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Gets or sets the css class of the filter button.
|
|
152
|
+
* @type {String}
|
|
153
|
+
*/
|
|
154
|
+
this.cssClassFilterButton = '';
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Gets or sets the css class of the filter menu.
|
|
158
|
+
* @type {String}
|
|
159
|
+
*/
|
|
160
|
+
this.cssClassFilterMenu = '';
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Gets or sets the css class of the filter from label.
|
|
164
|
+
* @type {String}
|
|
165
|
+
*/
|
|
166
|
+
this.cssClassFilterFrom = '';
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Gets or sets the css class of the filter to label.
|
|
170
|
+
* @type {String}
|
|
171
|
+
*/
|
|
172
|
+
this.cssClassFilterTo = '';
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Gets or sets the css class of the header label.
|
|
176
|
+
* @type {String}
|
|
177
|
+
*/
|
|
178
|
+
this.cssClassHeaderLabel = '';
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Gets or sets the css class of the resize handle.
|
|
182
|
+
* @type {String}
|
|
183
|
+
*/
|
|
184
|
+
this.cssClassResizeHandle = '';
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Gets or sets the css class of the drag ghost.
|
|
188
|
+
* @type {String}
|
|
189
|
+
*/
|
|
190
|
+
this.cssClassDragGhost = '';
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Gets or sets the css class of the preloader.
|
|
194
|
+
* @type {String}
|
|
195
|
+
*/
|
|
196
|
+
this.cssClassPreloader = '';
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Gets or sets the css class of the no result container.
|
|
200
|
+
* @type {String}
|
|
201
|
+
*/
|
|
202
|
+
this.cssClassNoResult = '';
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Gets or sets the css class of the check box.
|
|
206
|
+
* @type {String}
|
|
207
|
+
*/
|
|
208
|
+
this.cssClassCheckBox = '';
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Gets or sets the css class of the expand cell.
|
|
212
|
+
* @type {String}
|
|
213
|
+
*/
|
|
214
|
+
this.cssClassExpand = '';
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Gets or sets the css class of the expand icon.
|
|
218
|
+
* @type {String}
|
|
219
|
+
*/
|
|
220
|
+
this.cssClassExpandIcon = '';
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Gets or sets the css class of the item.
|
|
224
|
+
* @type {String}
|
|
225
|
+
*/
|
|
226
|
+
this.cssClassItem = '';
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Gets or sets the css class of a group-item.
|
|
230
|
+
* @type {String}
|
|
231
|
+
*/
|
|
232
|
+
this.cssClassGroupItem = '';
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Gets or sets the css class of a group-item head.
|
|
236
|
+
* @type {String}
|
|
237
|
+
*/
|
|
238
|
+
this.cssClassGroupHead = '';
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Gets or sets the css class of a fixed column.
|
|
242
|
+
* @type {String}
|
|
243
|
+
*/
|
|
244
|
+
this.cssClassFixedColumn = '';
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Gets or sets the css class of a hidden column.
|
|
248
|
+
* @type {String}
|
|
249
|
+
*/
|
|
250
|
+
this.cssClassHiddenColumn = '';
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Gets or sets the default template id of an item.
|
|
254
|
+
* @type {String|null}
|
|
255
|
+
*/
|
|
256
|
+
this.itemTemplateId = null;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Gets or sets the indent value of an item-group in pixels (defaults to 10).
|
|
260
|
+
* @type {Number}
|
|
261
|
+
*/
|
|
262
|
+
this.groupIndent = 10;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Gets or sets the amount of fixed columns at the left side of the grid which remain visible while scrolling horizontally.
|
|
266
|
+
* @type {Number}
|
|
267
|
+
*/
|
|
268
|
+
this.fixedColumns = 0;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Gets or sets the time in milliseconds between a horizontal scrolling action and updating the position of fixed columns accordingly (defaults to 100).
|
|
272
|
+
* @type {Number}
|
|
273
|
+
*/
|
|
274
|
+
this.fixedColumnScrollUpdate = 100;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Gets or sets the bottom offset in pixels for the viewport height. Only applicable when useViewportHeight is enabled.
|
|
278
|
+
* @type {Number}
|
|
279
|
+
*/
|
|
280
|
+
this.viewportBottomOffset = 0;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Gets or sets the height of the content container.
|
|
284
|
+
* @type {String}
|
|
285
|
+
*/
|
|
286
|
+
this.contentHeight = '';
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Gets or sets the style of the content container.
|
|
290
|
+
* @type {String}
|
|
291
|
+
*/
|
|
292
|
+
this.contentStyle = '';
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Gets or sets a value indicating whether column headers are draggable.
|
|
296
|
+
* @type {Boolean}
|
|
297
|
+
*/
|
|
298
|
+
this.draggableHeaders = true;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Gets or sets a value indicating whether column headers are resizable.
|
|
302
|
+
* @type {Boolean}
|
|
303
|
+
*/
|
|
304
|
+
this.resizableHeaders = true;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Gets or sets a value indicating whether data items are draggable.
|
|
308
|
+
* @type {Boolean}
|
|
309
|
+
*/
|
|
310
|
+
this.draggableItems = false;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Gets or sets a value indicating if the total width of the grid view is preserved when resizing a column. When enabled, resizing a column header will not change the total width of the grid, instead the change in width will be distributed over all resizable columns.
|
|
314
|
+
* @type {Boolean}
|
|
315
|
+
*/
|
|
316
|
+
this.preserveTotalWidth = false;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Gets or sets a value indicating whether the data pager is enabled.
|
|
320
|
+
* @type {Boolean}
|
|
321
|
+
*/
|
|
322
|
+
this.enableDataPager = false;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Gets or sets a value indicating whether the tooltip manager is enabled.
|
|
326
|
+
* @type {Boolean}
|
|
327
|
+
*/
|
|
328
|
+
this.enableTooltipManager = true;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Gets or sets a value indicating whether the filter row is enabled.
|
|
332
|
+
* @type {Boolean}
|
|
333
|
+
*/
|
|
334
|
+
this.enableFilterRow = true;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Gets or sets a value indicating whether the expand column is enabled.
|
|
338
|
+
* @type {Boolean}
|
|
339
|
+
*/
|
|
340
|
+
this.enableExpandColumn = true;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Gets or sets a value indicating whether the selection should be cleared on a click outside the grid.
|
|
344
|
+
* @type {Boolean}
|
|
345
|
+
*/
|
|
346
|
+
this.clearSelectionOnOutsideClick = false;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Gets or sets a value indicating whether the viewport height is utilized for the content container. The height calculation respects a possible bottom margin of the grid element.
|
|
350
|
+
* @type {Boolean}
|
|
351
|
+
*/
|
|
352
|
+
this.useViewportHeight = false;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Gets or sets the column sorting option.
|
|
356
|
+
* @type {componyx.UI.Grid.ColumnSortingOption}
|
|
357
|
+
*/
|
|
358
|
+
this.columnSorting = _columnSortingOption.NONE;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Gets or sets the row selection option.
|
|
362
|
+
* @type {componyx.UI.Grid.RowSelectionOption}
|
|
363
|
+
*/
|
|
364
|
+
this.rowSelection = _rowSelectionOption.NONE;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Gets or sets the row expansion option.
|
|
368
|
+
* @type {componyx.UI.Grid.RowExpansionOption}
|
|
369
|
+
*/
|
|
370
|
+
this.rowExpansion = _rowExpansionOption.NONE;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Gets or sets the item-group expansion option.
|
|
374
|
+
* @type {componyx.UI.Grid.GroupExpansionOption}
|
|
375
|
+
*/
|
|
376
|
+
this.groupExpansion = _groupExpansionOption.ICON;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Gets or sets friendly labels for filter menu options (EQUALTO, NOTEQUALTO, GREATERTHAN, GREATERTHANOREQUALTO, LESSTHAN, LESSTHANOREQUALTO, STARTSWITH, NOTSTARTSWITH, ENDSWITH, NOTENDSWITH, CONTAINS, NOTCONTAINS, BETWEEN, NOTBETWEEN, IN, NOTIN, EMPTY, NOTEMPTY)
|
|
380
|
+
* @type {Object<String, String>}
|
|
381
|
+
*/
|
|
382
|
+
this.filterMenuLabels = {};
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Gets or sets the filter from and to labels (0: FROM, 1: TO).
|
|
386
|
+
* @type {String[]}
|
|
387
|
+
*/
|
|
388
|
+
this.filterBetweenLabels = [];
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Gets or sets the list of items.
|
|
392
|
+
* @type {componyx.UI.Grid.Item[]|null}
|
|
393
|
+
*/
|
|
394
|
+
this.itemList = null;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Gets or sets the column groups.
|
|
398
|
+
* @type {componyx.UI.Grid.ColumnGroup[]}
|
|
399
|
+
*/
|
|
400
|
+
this.columnGroups = [];
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Gets or sets the columns.
|
|
404
|
+
* @type {componyx.UI.Grid.Column[]}
|
|
405
|
+
*/
|
|
406
|
+
this.columns = [];
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Gets or sets the id of the filter menu.
|
|
410
|
+
* @type {String|null}
|
|
411
|
+
*/
|
|
412
|
+
this.filterMenuId = null;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Gets or sets the id of the datapager.
|
|
416
|
+
* @type {String|null}
|
|
417
|
+
*/
|
|
418
|
+
this.dataPagerId = null;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Gets or sets the id of the tooltip manager used to display tooltips.
|
|
422
|
+
* @type {String|null}
|
|
423
|
+
*/
|
|
424
|
+
this.tooltipManagerId = null;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Gets or sets the drag settings for the draggable headers.
|
|
428
|
+
* @type {componyx.library.DraggableSettings}
|
|
429
|
+
*/
|
|
430
|
+
this.headerDragSettings = {};
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Gets or sets the drag settings for the draggable items.
|
|
434
|
+
* @type {componyx.library.DraggableSettings}
|
|
435
|
+
*/
|
|
436
|
+
this.itemDragSettings = {};
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Gets or sets the resize settings for the resizable headers.
|
|
440
|
+
* @type {componyx.library.ResizableSettings}
|
|
441
|
+
*/
|
|
442
|
+
this.headerResizeSettings = {};
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Gets or sets the select settings for the selectable items.
|
|
446
|
+
* @type {componyx.library.SelectableSettings}
|
|
447
|
+
*/
|
|
448
|
+
this.selectSettings = {};
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* @class
|
|
452
|
+
* @augments componyx.UI.base.Events
|
|
453
|
+
* @memberof componyx.UI.Grid
|
|
454
|
+
* @property {componyx.UI.base.Event} onItemClick - Event which fires on an item click. @see {@link componyx.UI.Grid.GridItemEventArgs}
|
|
455
|
+
* @property {componyx.UI.base.Event} onItemSelect - Event which fires on an item select. @see {@link componyx.UI.Grid.GridItemEventArgs}
|
|
456
|
+
* @property {componyx.UI.base.Event} onItemDeselect - Event which fires on an item deselect. @see {@link componyx.UI.Grid.GridItemEventArgs}
|
|
457
|
+
* @property {componyx.UI.base.Event} onItemExpand - Event which fires on an item expand. @see {@link componyx.UI.Grid.GridItemEventArgs}
|
|
458
|
+
* @property {componyx.UI.base.Event} onItemCollapse - Event which fires on an item collapse. @see {@link componyx.UI.Grid.GridItemEventArgs}
|
|
459
|
+
* @property {componyx.UI.base.Event} onItemGroupExpand - Event which fires on an item-group expand. @see {@link componyx.UI.Grid.GridItemEventArgs}
|
|
460
|
+
* @property {componyx.UI.base.Event} onItemGroupCollapse - Event which fires on an item-group collapse. @see {@link componyx.UI.Grid.GridItemEventArgs}
|
|
461
|
+
* @property {componyx.UI.base.Event} onPreRenderItem - Event which fires when an item is rendered. @see {@link componyx.UI.Grid.GridItemEventArgs}
|
|
462
|
+
* @property {componyx.UI.base.Event} onPostRenderItem - Event which fires when an item is rendered. @see {@link componyx.UI.Grid.GridItemEventArgs}
|
|
463
|
+
* @property {componyx.UI.base.Event} onPreLoadItemList - Event which fires before the item-list data is loaded. @see {@link componyx.UI.Grid.GridQueryEventArgs}
|
|
464
|
+
* @property {componyx.UI.base.Event} onPostLoadItemList - Event which fires when the item-list data is loaded. @see {@link componyx.UI.Grid.GridAjaxEventArgs}
|
|
465
|
+
* @property {componyx.UI.base.Event} onPostRenderItemList - Event which fires when the item-list is rendered. @see {@link componyx.UI.Grid.GridAjaxEventArgs}
|
|
466
|
+
* @property {componyx.UI.base.Event} onPreLoadItem - Event which fires before the item data is loaded. @see {@link componyx.UI.Grid.GridEventArgs}
|
|
467
|
+
* @property {componyx.UI.base.Event} onPostLoadItem - Event which fires when the item data is loaded. @see {@link componyx.UI.Grid.GridAjaxEventArgs}
|
|
468
|
+
* @property {componyx.UI.base.Event} onColumnOrderChange - Event which fires when the column order is changed. @see {@link componyx.UI.Grid.GridColumnOrderEventArgs}
|
|
469
|
+
* @property {componyx.UI.base.Event} onColumnResize - Event which fires when a column is resized. @see {@link componyx.UI.Grid.GridColumnResizeEventArgs}
|
|
470
|
+
* @property {componyx.UI.base.Event} onColumnSort - Event which fires when the list is sorted. @see {@link componyx.UI.Grid.GridColumnSortEventArgs}
|
|
471
|
+
* @property {componyx.UI.base.Event} onItemOrderChange - Event which fires when the item order is changed. @see {@link componyx.UI.Grid.GridItemOrderEventArgs}
|
|
472
|
+
* @see {@link componyx.UI.base.Events}
|
|
473
|
+
*/
|
|
474
|
+
function GridEvents(events)
|
|
475
|
+
{
|
|
476
|
+
Object.assign(this, events);
|
|
477
|
+
|
|
478
|
+
this.onItemClick = $base.static.createEvent('onItemClick');
|
|
479
|
+
this.onItemSelect = $base.static.createEvent('onItemSelect');
|
|
480
|
+
this.onItemDeselect = $base.static.createEvent('onItemDeselect');
|
|
481
|
+
this.onItemExpand = $base.static.createEvent('onItemExpand');
|
|
482
|
+
this.onItemCollapse = $base.static.createEvent('onItemCollapse');
|
|
483
|
+
this.onItemGroupExpand = $base.static.createEvent('onItemGroupExpand');
|
|
484
|
+
this.onItemGroupCollapse = $base.static.createEvent('onItemGroupCollapse');
|
|
485
|
+
this.onPreRenderItem = $base.static.createEvent('onPreRenderItem');
|
|
486
|
+
this.onPostRenderItem = $base.static.createEvent('onPostRenderItem');
|
|
487
|
+
this.onPreLoadItemList = $base.static.createEvent('onPreLoadItemList');
|
|
488
|
+
this.onPostLoadItemList = $base.static.createEvent('onPostLoadItemList');
|
|
489
|
+
this.onPostRenderItemList = $base.static.createEvent('onPostRenderItemList');
|
|
490
|
+
this.onPreLoadItem = $base.static.createEvent('onPreLoadItem');
|
|
491
|
+
this.onPostLoadItem = $base.static.createEvent('onPostLoadItem');
|
|
492
|
+
this.onColumnOrderChange = $base.static.createEvent('onColumnOrderChange');
|
|
493
|
+
this.onColumnResize = $base.static.createEvent('onColumnResize');
|
|
494
|
+
this.onColumnSort = $base.static.createEvent('onColumnSort');
|
|
495
|
+
this.onItemOrderChange = $base.static.createEvent('onItemOrderChange');
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Grid events
|
|
499
|
+
* @type {componyx.UI.Grid.GridEvents}
|
|
500
|
+
*/
|
|
501
|
+
this.events = new GridEvents(this.events);
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* @typedef {Object} componyx.UI.Grid.GridEventArgs
|
|
505
|
+
* @property {componyx.UI.Grid} Grid - The Grid instance.
|
|
506
|
+
*/
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* @typedef {Object} componyx.UI.Grid.GridItemEventArgs
|
|
510
|
+
* @property {componyx.UI.Grid} Grid - The Grid instance.
|
|
511
|
+
* @property {Object} eventArgs - The event object containing more detailed information about the event.
|
|
512
|
+
* @property {componyx.UI.Grid.Item} eventArgs.item - The grid item.
|
|
513
|
+
* @property {HTMLTableRowElement} eventArgs.tr - The table row of the item.
|
|
514
|
+
* @property {HTMLTableCellElement|null} eventArgs.td - The group-head cell (item-group expand/collapse) or the expand content cell (item expand), otherwise null.
|
|
515
|
+
* @property {Event} eventArgs.event - The original event object.
|
|
516
|
+
*/
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* @typedef {Object} componyx.UI.Grid.GridQueryEventArgs
|
|
520
|
+
* @property {componyx.UI.Grid} Grid - The Grid instance.
|
|
521
|
+
* @property {Object} eventArgs - The load query.
|
|
522
|
+
* @property {Object.<string, componyx.UI.Grid.SortOrderOption>} eventArgs.sortOrder - The sort order per column id.
|
|
523
|
+
* @property {Object} eventArgs.filter - The active filter.
|
|
524
|
+
* @property {number} eventArgs.pageIndex - The page index (1-based).
|
|
525
|
+
*/
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* @typedef {Object} componyx.UI.Grid.GridAjaxEventArgs
|
|
529
|
+
* @property {componyx.UI.Grid} Grid - The Grid instance.
|
|
530
|
+
* @property {Object|undefined} eventArgs - The ajax result arguments, undefined when no ajax load method is defined (item-list events only).
|
|
531
|
+
* @property {string|Object} eventArgs.data - The response data.
|
|
532
|
+
*/
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* @typedef {Object} componyx.UI.Grid.GridColumnSortEventArgs
|
|
536
|
+
* @property {componyx.UI.Grid} Grid - The Grid instance.
|
|
537
|
+
* @property {Object} eventArgs - The event object containing more detailed information about the event.
|
|
538
|
+
* @property {string} eventArgs.columnId - The column id.
|
|
539
|
+
* @property {componyx.UI.Grid.SortOrderOption|undefined} eventArgs.order - The new sort order, undefined when sorting was removed.
|
|
540
|
+
*/
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* @typedef {Object} componyx.UI.Grid.GridColumnOrderEventArgs
|
|
544
|
+
* @property {componyx.UI.Grid} Grid - The Grid instance.
|
|
545
|
+
* @property {Object} eventArgs - The event object containing more detailed information about the event.
|
|
546
|
+
* @property {number} eventArgs.sourceIndex - The original column index.
|
|
547
|
+
* @property {number} eventArgs.targetIndex - The new column index.
|
|
548
|
+
*/
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* @typedef {Object} componyx.UI.Grid.GridColumnResizeEventArgs
|
|
552
|
+
* @property {componyx.UI.Grid} Grid - The Grid instance.
|
|
553
|
+
* @property {Object} eventArgs - The event object containing more detailed information about the event.
|
|
554
|
+
* @property {number} eventArgs.columnIndex - The column index.
|
|
555
|
+
* @property {HTMLElement} eventArgs.element - The resized header element.
|
|
556
|
+
*/
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* @typedef {Object} componyx.UI.Grid.GridItemOrderEventArgs
|
|
560
|
+
* @property {componyx.UI.Grid} Grid - The Grid instance.
|
|
561
|
+
* @property {Object} eventArgs - The event object containing more detailed information about the event.
|
|
562
|
+
* @property {componyx.UI.Grid.Item[]} eventArgs.items - The moved items (a group item includes its child items).
|
|
563
|
+
* @property {number} eventArgs.fromIndex - The original item index.
|
|
564
|
+
* @property {number} eventArgs.toIndex - The target item index.
|
|
565
|
+
* @property {number} eventArgs.resultIndex - The resulting index after the move.
|
|
566
|
+
* @property {HTMLElement} eventArgs.dropZone - The drop zone (table row) the items were dropped on.
|
|
567
|
+
* @property {HTMLElement|null} eventArgs.nextRow - The row before which the items were inserted, null when appended at the end.
|
|
568
|
+
*/
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
// inherit base instance members
|
|
572
|
+
$base.Component.apply(this, [id, properties]);
|
|
573
|
+
|
|
574
|
+
// define ajax method
|
|
575
|
+
this.ajax.addMethod('loadItem');
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Sets the preloader template.
|
|
579
|
+
* @param {HTMLElement|HTMLElement[]|DocumentFragment|String} content The content template. Pass null or empty string to remove the existing template.
|
|
580
|
+
*/
|
|
581
|
+
this.setPreloaderTemplate = function (content)
|
|
582
|
+
{
|
|
583
|
+
_instance.addTemplate('Preloader', content, false);
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Sets the item preloader template.
|
|
588
|
+
* @param {HTMLElement|HTMLElement[]|DocumentFragment|String} content The content template. Pass null or empty string to remove the existing template.
|
|
589
|
+
*/
|
|
590
|
+
this.setItemPreloaderTemplate = function (content)
|
|
591
|
+
{
|
|
592
|
+
_instance.addTemplate('ItemPreloader', content, false);
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Sets the no result template.
|
|
597
|
+
* @param {HTMLElement|HTMLElement[]|DocumentFragment|String} content The content template. Pass null or empty string to remove the existing template.
|
|
598
|
+
*/
|
|
599
|
+
this.setNoResultTemplate = function (content)
|
|
600
|
+
{
|
|
601
|
+
_instance.addTemplate('NoResult', content, false);
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Selects/deselects the item with the specified id.
|
|
606
|
+
* @param {String} id Item id
|
|
607
|
+
*/
|
|
608
|
+
this.toggleSelectItem = function (id)
|
|
609
|
+
{
|
|
610
|
+
_forceSelect = true;
|
|
611
|
+
toggleSelectItem(id);
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Selects the items with the specified id.
|
|
616
|
+
* @param {Array} ids The list of item ids.
|
|
617
|
+
*/
|
|
618
|
+
this.selectItems = function (ids)
|
|
619
|
+
{
|
|
620
|
+
for (var index = 0; index < ids.length; ++index)
|
|
621
|
+
{
|
|
622
|
+
_instance.selectItem(ids[index]);
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Deselects the items with the specified id.
|
|
628
|
+
* @param {Array} ids The list of item ids.
|
|
629
|
+
*/
|
|
630
|
+
this.deselectItems = function (ids)
|
|
631
|
+
{
|
|
632
|
+
for (var index = 0; index < ids.length; ++index)
|
|
633
|
+
{
|
|
634
|
+
deselectItem(ids[index]);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Selects the item with the specified id.
|
|
640
|
+
* @param {String} id Item id
|
|
641
|
+
*/
|
|
642
|
+
this.selectItem = function (id)
|
|
643
|
+
{
|
|
644
|
+
_forceSelect = true;
|
|
645
|
+
selectItem(id);
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Deselects the item with the specified id.
|
|
650
|
+
* @param {String} id Item id
|
|
651
|
+
*/
|
|
652
|
+
this.deselectItem = function (id)
|
|
653
|
+
{
|
|
654
|
+
deselectItem(id);
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Expands/collapses the item with the specified id.
|
|
659
|
+
* @param {String} id Item id
|
|
660
|
+
*/
|
|
661
|
+
this.toggleExpandItem = function (id)
|
|
662
|
+
{
|
|
663
|
+
toggleExpandItem(id);
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Expands the item with the specified id.
|
|
668
|
+
* @param {String} id Item id
|
|
669
|
+
*/
|
|
670
|
+
this.expandItem = function (id)
|
|
671
|
+
{
|
|
672
|
+
expandItem(id);
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Collapses the item with the specified id.
|
|
677
|
+
* @param {String} id Item id
|
|
678
|
+
*/
|
|
679
|
+
this.collapseItem = function (id)
|
|
680
|
+
{
|
|
681
|
+
collapseItem(id);
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Expands/collapses the item-group with the specified id.
|
|
686
|
+
* @param {String} id Item id
|
|
687
|
+
*/
|
|
688
|
+
this.toggleExpandItemGroup = function (id)
|
|
689
|
+
{
|
|
690
|
+
expandItemGroup(id, null);
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Expands the item-group with the specified id.
|
|
695
|
+
* @param {String} id Item id
|
|
696
|
+
*/
|
|
697
|
+
this.expandItemGroup = function (id)
|
|
698
|
+
{
|
|
699
|
+
expandItemGroup(id, true);
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Collapses the item-group with the specified id.
|
|
704
|
+
* @param {String} id Item id
|
|
705
|
+
*/
|
|
706
|
+
this.collapseItemGroup = function (id)
|
|
707
|
+
{
|
|
708
|
+
expandItemGroup(id, false);
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Enables the item with the specified id.
|
|
713
|
+
* @param {String} id Item id
|
|
714
|
+
*/
|
|
715
|
+
this.enableItem = function (id)
|
|
716
|
+
{
|
|
717
|
+
enableItem(id);
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Disables the item with the specified id.
|
|
722
|
+
* @param {String} id Item id
|
|
723
|
+
*/
|
|
724
|
+
this.disableItem = function (id)
|
|
725
|
+
{
|
|
726
|
+
disableItem(id);
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Returns the grid column group index with the specified id.
|
|
731
|
+
* @param {String} id The column id.
|
|
732
|
+
*/
|
|
733
|
+
this.getColumnGroupIndex = function (id)
|
|
734
|
+
{
|
|
735
|
+
return getIndex(_instance.columnGroups, id);
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Returns the grid column group with the specified id.
|
|
740
|
+
* @param {String} id The column id.
|
|
741
|
+
*/
|
|
742
|
+
this.getColumnGroup = function (id)
|
|
743
|
+
{
|
|
744
|
+
return _instance.columnGroups[getIndex(_instance.columnGroups, id)];
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Removes a column group header from the grid.
|
|
749
|
+
* @param {String} id The id of the column group.
|
|
750
|
+
*/
|
|
751
|
+
this.removeColumnGroup = function (id)
|
|
752
|
+
{
|
|
753
|
+
_instance.columnGroups.splice(getIndex(_instance.columnGroups, id), 1);
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Returns the grid column index with the specified id.
|
|
758
|
+
* @param {String} id The column id.
|
|
759
|
+
*/
|
|
760
|
+
this.getColumnIndex = function (id)
|
|
761
|
+
{
|
|
762
|
+
return getIndex(_instance.columns, id);
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Returns the grid column with the specified id.
|
|
767
|
+
* @param {String} id The column id.
|
|
768
|
+
*/
|
|
769
|
+
this.getColumn = function (id)
|
|
770
|
+
{
|
|
771
|
+
return _instance.columns[getIndex(_instance.columns, id)];
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Removes a column from the grid.
|
|
776
|
+
* @param {String} id The id of the column.
|
|
777
|
+
*/
|
|
778
|
+
this.removeColumn = function (id)
|
|
779
|
+
{
|
|
780
|
+
_instance.columns.splice(getIndex(_instance.columns, id), 1);
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Shows a columnGroup in the grid.
|
|
785
|
+
* @param {String} id The id of the columnGroup.
|
|
786
|
+
*/
|
|
787
|
+
this.showColumnGroup = function (id)
|
|
788
|
+
{
|
|
789
|
+
setColumnGroupDisplay(id, true);
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Hides a columnGroup in the grid.
|
|
794
|
+
* @param {String} id The id of the columnGroup.
|
|
795
|
+
*/
|
|
796
|
+
this.hideColumnGroup = function (id)
|
|
797
|
+
{
|
|
798
|
+
setColumnGroupDisplay(id, false);
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Shows a column in the grid.
|
|
803
|
+
* @param {String} id The id of the column.
|
|
804
|
+
*/
|
|
805
|
+
this.showColumn = function (id)
|
|
806
|
+
{
|
|
807
|
+
setColumnDisplay(id, true);
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Hides a column in the grid.
|
|
812
|
+
* @param {String} id The id of the column.
|
|
813
|
+
*/
|
|
814
|
+
this.hideColumn = function (id)
|
|
815
|
+
{
|
|
816
|
+
setColumnDisplay(id, false);
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Returns the selectable object which enables grid table elements to be selectable.
|
|
821
|
+
*/
|
|
822
|
+
this.selectable = function ()
|
|
823
|
+
{
|
|
824
|
+
return _selectable;
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Disables selection on elements for the current click event. Selection is automatically re-enabled when the current event bubbles to the document click.
|
|
829
|
+
*/
|
|
830
|
+
this.cancelSelectClick = function ()
|
|
831
|
+
{
|
|
832
|
+
_cancelSelect = true;
|
|
833
|
+
|
|
834
|
+
if (_selectable)
|
|
835
|
+
_selectable.disable();
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Filters the grid.
|
|
840
|
+
*
|
|
841
|
+
* @param {Object} columns
|
|
842
|
+
* Plain Object with column id as key and a Plain Object as value.
|
|
843
|
+
* The value Object properties:
|
|
844
|
+
* value (String): The filter value.
|
|
845
|
+
* [type] (FilterMenuOptions): One or more of the options.
|
|
846
|
+
* [updateInput] (Boolean): Value indicating if the corresponding filter input value should be updated (default true).
|
|
847
|
+
*
|
|
848
|
+
* @param {Boolean} [autoLoad] Defines if the grid should reload data.
|
|
849
|
+
* @param {Boolean} [clear] Defines if the current selection should be cleared.
|
|
850
|
+
*/
|
|
851
|
+
this.filter = function (columns, autoLoad, clear)
|
|
852
|
+
{
|
|
853
|
+
for (var columnId in columns)
|
|
854
|
+
{
|
|
855
|
+
setColumnFilter(columnId, columns[columnId].value, columns[columnId].type);
|
|
856
|
+
|
|
857
|
+
if (_instance.enableFilterRow && columns[columnId].updateInput != false)
|
|
858
|
+
{
|
|
859
|
+
setFilterValue(columnId, columns[columnId].value);
|
|
860
|
+
_filterMenu.selectItem(columnId);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
if (autoLoad != false)
|
|
865
|
+
load(clear);
|
|
866
|
+
};
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* Sorts the grid.
|
|
870
|
+
* @param {Object} columns Object with column id as key and one of the options from componyx.UI.Grid.SortOrderOption as value.
|
|
871
|
+
* @param {Boolean} [autoLoad] Defines if the grid should reload data.
|
|
872
|
+
* @param {Boolean} [clear] Defines if the current selection should be cleared.
|
|
873
|
+
*/
|
|
874
|
+
this.sort = function (columns, autoLoad, clear)
|
|
875
|
+
{
|
|
876
|
+
for (var columnId in columns)
|
|
877
|
+
{
|
|
878
|
+
setColumnSortOrder(columnId, columns[columnId]);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
if (autoLoad != false)
|
|
882
|
+
load(clear);
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Triggers a data load.
|
|
887
|
+
* @param {Boolean} [clear] Defines if the current selection should be cleared.
|
|
888
|
+
* @param {Number} [pageIndex] Defines which page index to load.
|
|
889
|
+
*/
|
|
890
|
+
this.load = function (clear, pageIndex)
|
|
891
|
+
{
|
|
892
|
+
if (clear)
|
|
893
|
+
clearSelection();
|
|
894
|
+
|
|
895
|
+
load(pageIndex);
|
|
896
|
+
};
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Returns the grid item with the specified id.
|
|
900
|
+
* @param {String} id The item id.
|
|
901
|
+
*/
|
|
902
|
+
this.getItem = function (id)
|
|
903
|
+
{
|
|
904
|
+
return _instance.itemList[getIndex(_instance.itemList, id)];
|
|
905
|
+
};
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Removes the grid item with the specified id.
|
|
909
|
+
* @param {String} id The item id.
|
|
910
|
+
*/
|
|
911
|
+
this.removeItem = function (id)
|
|
912
|
+
{
|
|
913
|
+
removeItem(id);
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Renders the specified item by creating a new table record or overwriting the existing table record in the grid.
|
|
918
|
+
* The item must exist in the item list and the item's position in the item group will equal the item's position within the item list.
|
|
919
|
+
* @param {componyx.UI.Grid.Item} item The item to render.
|
|
920
|
+
*/
|
|
921
|
+
this.renderItem = function (item)
|
|
922
|
+
{
|
|
923
|
+
var table = _divContent.firstChild;
|
|
924
|
+
|
|
925
|
+
if (_divPreloader != null)
|
|
926
|
+
_divPreloader.style.display = 'none';
|
|
927
|
+
if (_divNoResult != null)
|
|
928
|
+
_divNoResult.style.display = 'none';
|
|
929
|
+
|
|
930
|
+
// display table
|
|
931
|
+
table.style.display = '';
|
|
932
|
+
drawItem(table, item, getIndex(_instance.itemList, item.id));
|
|
933
|
+
|
|
934
|
+
if (_selectable)
|
|
935
|
+
_selectable.update();
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Renders the component.
|
|
940
|
+
*/
|
|
941
|
+
this.render = async function ()
|
|
942
|
+
{
|
|
943
|
+
if (_instance.renderState != $base.static.RenderState.RENDERING)
|
|
944
|
+
{
|
|
945
|
+
// call base render and return
|
|
946
|
+
$base.methods.render.call(_instance, preRender, 'grid');
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
if (_instance.enableFilterRow && componyx.UI.menu_modules)
|
|
951
|
+
await componyx.UI.menu_modules.loaded; // we wait before the menu and it's modules are loaded
|
|
952
|
+
|
|
953
|
+
// render logic after loading resources
|
|
954
|
+
draw();
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Handles the post render procedure.
|
|
959
|
+
*/
|
|
960
|
+
this.postRender = function ()
|
|
961
|
+
{
|
|
962
|
+
if (_instance.renderState != $base.static.RenderState.RENDERING) // extra safety to never execute a postRender when the component state is incorrect
|
|
963
|
+
return;
|
|
964
|
+
|
|
965
|
+
postRender();
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Destroys the component.
|
|
970
|
+
* @see {@link componyx.UI.base.methods#destroy}
|
|
971
|
+
*/
|
|
972
|
+
this.destroy = function (...args)
|
|
973
|
+
{
|
|
974
|
+
dispose();
|
|
975
|
+
$base.methods.destroy.call(this, ...args);
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
function preRender()
|
|
979
|
+
{
|
|
980
|
+
// initialize script and css
|
|
981
|
+
var cssClassFixedColumn = _instance.cssClassFixedColumn || _classOption.FIXED_COLUMN,
|
|
982
|
+
script = [],
|
|
983
|
+
cssId = 'componyx.UI.Grid.global';
|
|
984
|
+
|
|
985
|
+
if (_instance.enableDataPager)
|
|
986
|
+
script.push('DataPager');
|
|
987
|
+
|
|
988
|
+
script.push('Box');
|
|
989
|
+
script.push('TooltipManager');
|
|
990
|
+
script.push('Button');
|
|
991
|
+
|
|
992
|
+
if (_instance.fixedColumns > 0)
|
|
993
|
+
{
|
|
994
|
+
_fixedColumnStyleSheet = $lib.getStyleSheet(cssId);
|
|
995
|
+
|
|
996
|
+
if (!_fixedColumnStyleSheet)
|
|
997
|
+
{
|
|
998
|
+
$lib.addCssTag($lib.format('#{0} .{1} { }', _instance.id, cssClassFixedColumn), cssId);
|
|
999
|
+
_fixedColumnStyleSheet = $lib.getStyleSheet(cssId);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
if (_instance.enableFilterRow)
|
|
1004
|
+
{
|
|
1005
|
+
var comparer = function (type)
|
|
1006
|
+
{
|
|
1007
|
+
return function (col) { return (!col.disableFilter && !col.filterTemplate && col.filterInputType === type) };
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
script.push('Menu');
|
|
1011
|
+
|
|
1012
|
+
if ($lib.indexOf(_instance.columns, comparer(_filterInputTypeOption.NUMERICBOX)) > -1)
|
|
1013
|
+
script.push('NumericBox');
|
|
1014
|
+
|
|
1015
|
+
if ($lib.indexOf(_instance.columns, comparer(_filterInputTypeOption.COMBOBOX)) > -1)
|
|
1016
|
+
script.push('ComboBox');
|
|
1017
|
+
|
|
1018
|
+
if ($lib.indexOf(_instance.columns, comparer(_filterInputTypeOption.DATEPICKER)) > -1)
|
|
1019
|
+
script.push('DatePicker');
|
|
1020
|
+
|
|
1021
|
+
if ($lib.indexOf(_instance.columns, comparer(_filterInputTypeOption.TIMEPICKER)) > -1)
|
|
1022
|
+
script.push('TimePicker');
|
|
1023
|
+
|
|
1024
|
+
if ($lib.indexOf(_instance.columns, comparer(_filterInputTypeOption.SLIDER)) > -1)
|
|
1025
|
+
script.push('Slider');
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
return ['Grid', script];
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
function postRender()
|
|
1032
|
+
{
|
|
1033
|
+
if (!$base.methods.postRender.call(_instance)) // component got destroyed on postrender event
|
|
1034
|
+
return;
|
|
1035
|
+
|
|
1036
|
+
load();
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
function load(pageIndex)
|
|
1040
|
+
{
|
|
1041
|
+
let query =
|
|
1042
|
+
{
|
|
1043
|
+
sortOrder: _sort,
|
|
1044
|
+
filter: _filter,
|
|
1045
|
+
pageIndex: pageIndex || 1
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
_instance.events.onPreLoadItemList.fire(_instance, query);
|
|
1049
|
+
|
|
1050
|
+
_expandedItemId = null;
|
|
1051
|
+
_lastItem = null;
|
|
1052
|
+
_loading = true;
|
|
1053
|
+
|
|
1054
|
+
if (_pager)
|
|
1055
|
+
_pager.hide();
|
|
1056
|
+
|
|
1057
|
+
if (_instance.ajax.load && _instance.ajax.load.isDefined())
|
|
1058
|
+
{
|
|
1059
|
+
showPreloader();
|
|
1060
|
+
|
|
1061
|
+
if (_ajax[0])
|
|
1062
|
+
_ajax[0].abort();
|
|
1063
|
+
|
|
1064
|
+
_ajax[0] = _instance.ajaxCall('load', window.JSON.stringify(query),
|
|
1065
|
+
{
|
|
1066
|
+
onSuccess: function (args)
|
|
1067
|
+
{
|
|
1068
|
+
dataLoaded(pageIndex || -1, args);
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
else
|
|
1073
|
+
dataLoaded();
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
function dataLoaded(pageIndex, ajaxArgs)
|
|
1077
|
+
{
|
|
1078
|
+
var ajaxResult = null;
|
|
1079
|
+
|
|
1080
|
+
_loading = false;
|
|
1081
|
+
|
|
1082
|
+
if (ajaxArgs)
|
|
1083
|
+
{
|
|
1084
|
+
_instance.itemList = [];
|
|
1085
|
+
if (ajaxArgs.data)
|
|
1086
|
+
{
|
|
1087
|
+
ajaxResult = (typeof ajaxArgs.data === 'string') ? window.JSON.parse(ajaxArgs.data) : ajaxArgs.data;
|
|
1088
|
+
_instance.itemList = (ajaxResult) ? ajaxResult.itemList || [] : [];
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
else if (_instance.itemList)
|
|
1092
|
+
_instance.itemList = (typeof _instance.itemList === 'string') ? window.JSON.parse(_instance.itemList) : _instance.itemList || [];
|
|
1093
|
+
|
|
1094
|
+
if (!_instance.itemList)
|
|
1095
|
+
_instance.itemList = [];
|
|
1096
|
+
|
|
1097
|
+
setupPager(ajaxResult, pageIndex);
|
|
1098
|
+
_instance.events.onPostLoadItemList.fire(_instance, ajaxArgs);
|
|
1099
|
+
|
|
1100
|
+
if (_instance.itemList.length > 0)
|
|
1101
|
+
drawItemList();
|
|
1102
|
+
else
|
|
1103
|
+
showNoResult();
|
|
1104
|
+
|
|
1105
|
+
detectViewportSize();
|
|
1106
|
+
_instance.events.onPostRenderItemList.fire(_instance, ajaxArgs);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
function setupPager(ajaxResult, pageIndex)
|
|
1110
|
+
{
|
|
1111
|
+
if (_pager && ajaxResult && ajaxResult.totalItemCount && ajaxResult.totalItemCount > ajaxResult.itemList.length)
|
|
1112
|
+
{
|
|
1113
|
+
_pager.itemCount = ajaxResult.totalItemCount;
|
|
1114
|
+
|
|
1115
|
+
if (pageIndex == -1)
|
|
1116
|
+
_pager.setPageIndex(1);
|
|
1117
|
+
else
|
|
1118
|
+
_pager.setPageIndex(pageIndex);
|
|
1119
|
+
|
|
1120
|
+
_pager.show();
|
|
1121
|
+
}
|
|
1122
|
+
else if (_pager)
|
|
1123
|
+
_pager.hide();
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
function draw()
|
|
1127
|
+
{
|
|
1128
|
+
_scrollbarSize = $lib.getScrollBarSize();
|
|
1129
|
+
|
|
1130
|
+
if (_instance.enableTooltipManager)
|
|
1131
|
+
createTooltipManager();
|
|
1132
|
+
|
|
1133
|
+
createHeader();
|
|
1134
|
+
createContent();
|
|
1135
|
+
_hidden = _instance.createSyncedInput();
|
|
1136
|
+
|
|
1137
|
+
if (_instance.enableDataPager)
|
|
1138
|
+
createDataPager();
|
|
1139
|
+
|
|
1140
|
+
$lib.on(window, 'resize', detectViewportSize);
|
|
1141
|
+
_documentHandler.push($lib.on(document, 'click', function ()
|
|
1142
|
+
{
|
|
1143
|
+
if (_selectable && _cancelSelect)
|
|
1144
|
+
_selectable.enable();
|
|
1145
|
+
|
|
1146
|
+
_cancelSelect = false;
|
|
1147
|
+
}));
|
|
1148
|
+
|
|
1149
|
+
bindOutsideClickHandler();
|
|
1150
|
+
_instance.renderChildren();
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
function bindOutsideClickHandler()
|
|
1154
|
+
{
|
|
1155
|
+
if (_instance.clearSelectionOnOutsideClick)
|
|
1156
|
+
{
|
|
1157
|
+
_elementHandler = $lib.on(_instance.element, 'pointerdown', function () { _outsideClick = false; }, null, _instance);
|
|
1158
|
+
_documentHandler.push($lib.on(document, 'pointerup', function (e)
|
|
1159
|
+
{
|
|
1160
|
+
if (_outsideClick)
|
|
1161
|
+
clearSelection();
|
|
1162
|
+
|
|
1163
|
+
_outsideClick = true;
|
|
1164
|
+
}, null, _instance));
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
function createTooltipManager()
|
|
1169
|
+
{
|
|
1170
|
+
var id = _instance.id + '_TooltipManager';
|
|
1171
|
+
|
|
1172
|
+
_tooltipManager = $UI.createComponent(componyx.UI.TooltipManager, { id: id, containerElement: _instance.element });
|
|
1173
|
+
_tooltipManager.clone($UI.store[_instance.tooltipManagerId], _instance, true, true, { triggers: '' });
|
|
1174
|
+
|
|
1175
|
+
if (!_tooltipManager.boxId)
|
|
1176
|
+
{
|
|
1177
|
+
var box = $UI.createComponent(componyx.UI.Box, { id: id + '_TempBox', containerElement: _instance.element });
|
|
1178
|
+
box.expandDirection = componyx.UI.Box.ExpandDirectionOption.DOWN;
|
|
1179
|
+
box.autoPosition = componyx.UI.Box.AutoPositionOption.EXPAND;
|
|
1180
|
+
box.alignX = componyx.UI.Box.AlignXOption.CENTER;
|
|
1181
|
+
box.autoInvertFit = true;
|
|
1182
|
+
_tooltipManager.boxId = box.id;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
_tooltipManager.showing = true;
|
|
1186
|
+
_tooltipManager.events.onPostRender.priorityAdd(function () { _instance.isReady.apply(_instance); }, null);
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
function createHeader()
|
|
1190
|
+
{
|
|
1191
|
+
var div = _instance.element.appendChild(document.createElement('div')),
|
|
1192
|
+
table = div.appendChild(document.createElement('div')).appendChild(document.createElement('table')),
|
|
1193
|
+
dragGhost = createDragGhost(div.firstChild),
|
|
1194
|
+
colgroup = table.appendChild(document.createElement('colgroup'));
|
|
1195
|
+
table.appendChild(document.createElement('tbody'));
|
|
1196
|
+
var cssClassCheckBox = _instance.cssClassCheckBox || _classOption.CHECKBOX,
|
|
1197
|
+
cssClassExpand = _instance.cssClassExpand || _classOption.EXPAND,
|
|
1198
|
+
cssClassHiddenColumn = _instance.cssClassHiddenColumn || _classOption.HIDDEN_COLUMN,
|
|
1199
|
+
cssClassFixedColumn = _instance.cssClassFixedColumn || _classOption.FIXED_COLUMN,
|
|
1200
|
+
cell, column, groupId, group, groups = {}, rowNum = 0, index, rows = [], fixed,
|
|
1201
|
+
resizeHandle, maxDepth, spanSelectAll, container, tooltipTemplate;
|
|
1202
|
+
|
|
1203
|
+
_headerDraggables = {};
|
|
1204
|
+
_depthLevels = getDepthLevels();
|
|
1205
|
+
maxDepth = _depthLevels[0];
|
|
1206
|
+
|
|
1207
|
+
div.className = _instance.cssClassHeader || _classOption.HEADER;
|
|
1208
|
+
_divHeader = div;
|
|
1209
|
+
|
|
1210
|
+
if (_instance.resizableHeaders)
|
|
1211
|
+
$lib.addClass(div, _classOption.RESIZABLE);
|
|
1212
|
+
|
|
1213
|
+
if (_instance.draggableHeaders)
|
|
1214
|
+
$lib.addClass(div, _classOption.DRAGGABLE);
|
|
1215
|
+
|
|
1216
|
+
for (index = 0; index < maxDepth; ++index)
|
|
1217
|
+
{
|
|
1218
|
+
// create total rows
|
|
1219
|
+
rows.push(table.insertRow(-1));
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
for (index = (showExpandColumn()) ? -1 : 0; index < _instance.columns.length; ++index)
|
|
1223
|
+
{
|
|
1224
|
+
spanSelectAll = null;
|
|
1225
|
+
column = _instance.columns[index] || null;
|
|
1226
|
+
rowNum = (index > -1) ? _depthLevels[1][column.id] - 1 : 0;
|
|
1227
|
+
fixed = (_instance.fixedColumns > 0 && index < _instance.fixedColumns);
|
|
1228
|
+
|
|
1229
|
+
cell = document.createElement('th');
|
|
1230
|
+
cell.rowSpan = maxDepth - rowNum;
|
|
1231
|
+
container = cell.appendChild(document.createElement('div')).appendChild(document.createElement('span'));
|
|
1232
|
+
container.className = _instance.cssClassHeaderLabel || _classOption.HEADER_LABEL;
|
|
1233
|
+
|
|
1234
|
+
// add col to colgroup
|
|
1235
|
+
var col = colgroup.appendChild(document.createElement('col'));
|
|
1236
|
+
// add at correct row index
|
|
1237
|
+
rows[rowNum].appendChild(cell);
|
|
1238
|
+
|
|
1239
|
+
if (index == -1)
|
|
1240
|
+
{
|
|
1241
|
+
$lib.addClass(cell, cssClassExpand);
|
|
1242
|
+
$lib.addClass(col, cssClassExpand);
|
|
1243
|
+
|
|
1244
|
+
if (fixed)
|
|
1245
|
+
$lib.addClass(cell, cssClassFixedColumn);
|
|
1246
|
+
|
|
1247
|
+
continue;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
groupId = column.columnGroupId;
|
|
1251
|
+
cell.id = _instance.id + '_h_' + column.id;
|
|
1252
|
+
cell.setAttribute('tabindex', '0');
|
|
1253
|
+
tooltipTemplate = (column.headerTooltipTemplate) ? column.headerTooltipTemplate : _instance.getTemplateContent('HeaderTooltip_' + column.id);
|
|
1254
|
+
|
|
1255
|
+
column.headerText = ($lib.isEmpty(column.headerText)) ? '' : column.headerText;
|
|
1256
|
+
|
|
1257
|
+
if (column.visible == false)
|
|
1258
|
+
{
|
|
1259
|
+
$lib.addClass(col, cssClassHiddenColumn);
|
|
1260
|
+
$lib.addClass(cell, cssClassHiddenColumn);
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
if (fixed)
|
|
1264
|
+
$lib.addClass(cell, cssClassFixedColumn);
|
|
1265
|
+
|
|
1266
|
+
if (tooltipTemplate)
|
|
1267
|
+
{
|
|
1268
|
+
// header tooltip
|
|
1269
|
+
column.headerTooltipTemplate = tooltipTemplate;
|
|
1270
|
+
|
|
1271
|
+
if (_tooltipManager)
|
|
1272
|
+
{
|
|
1273
|
+
_tooltipManager.addTooltip(column.id, tooltipTemplate);
|
|
1274
|
+
_tooltipManager.addTrigger(cell.id, column.id);
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
if (column.columnTemplate)
|
|
1279
|
+
_instance.addTemplate('Column_' + column.id, column.columnTemplate);
|
|
1280
|
+
|
|
1281
|
+
if (column.filterTemplate)
|
|
1282
|
+
_instance.addTemplate('Filter_' + column.id, column.filterTemplate);
|
|
1283
|
+
|
|
1284
|
+
$lib.addClass(cell, column.cssClassHeader || _classOption.COLUMN);
|
|
1285
|
+
|
|
1286
|
+
if (column.style)
|
|
1287
|
+
$lib.updateStyle(cell.style, column.style);
|
|
1288
|
+
|
|
1289
|
+
if (column.cssClassHeader)
|
|
1290
|
+
$lib.addClass(col, column.cssClassHeader);
|
|
1291
|
+
|
|
1292
|
+
if (!$lib.isEmpty(column.width))
|
|
1293
|
+
col.style.width = $lib.unit(column.width);
|
|
1294
|
+
|
|
1295
|
+
if (column.checkBox)
|
|
1296
|
+
{
|
|
1297
|
+
$lib.addClass(cell, cssClassCheckBox);
|
|
1298
|
+
$lib.addClass(col, cssClassCheckBox);
|
|
1299
|
+
|
|
1300
|
+
if (_instance.rowSelection == _rowSelectionOption.MULTI)
|
|
1301
|
+
{
|
|
1302
|
+
spanSelectAll = container.appendChild(document.createElement('span'));
|
|
1303
|
+
spanSelectAll.className = cssClassCheckBox;
|
|
1304
|
+
|
|
1305
|
+
if (!$lib.isEmpty(column.headerText))
|
|
1306
|
+
container.appendChild(document.createTextNode(column.headerText));
|
|
1307
|
+
|
|
1308
|
+
$lib.on(spanSelectAll, 'click', selectAll, [spanSelectAll]);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
else
|
|
1312
|
+
{
|
|
1313
|
+
container.innerHTML = column.headerText;
|
|
1314
|
+
|
|
1315
|
+
if (_instance.resizableHeaders && column.resizable != false)
|
|
1316
|
+
{
|
|
1317
|
+
resizeHandle = cell.firstChild.appendChild(document.createElement('span'));
|
|
1318
|
+
resizeHandle.className = _instance.cssClassResizeHandle || _classOption.RESIZE_HANDLE;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
if (!$lib.isEmpty(groupId))
|
|
1323
|
+
{
|
|
1324
|
+
while (!$lib.isEmpty(groupId))
|
|
1325
|
+
{
|
|
1326
|
+
group = _instance.columnGroups[getIndex(_instance.columnGroups, groupId)];
|
|
1327
|
+
|
|
1328
|
+
// add group only once
|
|
1329
|
+
if (!groups[groupId])
|
|
1330
|
+
{
|
|
1331
|
+
cell = document.createElement('th');
|
|
1332
|
+
cell.colSpan = 1;
|
|
1333
|
+
groups[groupId] = cell;
|
|
1334
|
+
|
|
1335
|
+
container = cell.appendChild(document.createElement('div')).appendChild(document.createElement('span'));
|
|
1336
|
+
container.innerHTML = group.headerText;
|
|
1337
|
+
|
|
1338
|
+
$lib.addClass(cell, group.cssClass || _classOption.COLUMN_GROUP);
|
|
1339
|
+
|
|
1340
|
+
if (fixed)
|
|
1341
|
+
$lib.addClass(cell, cssClassFixedColumn);
|
|
1342
|
+
|
|
1343
|
+
if (group.style)
|
|
1344
|
+
$lib.updateStyle(cell.style, group.style);
|
|
1345
|
+
|
|
1346
|
+
// insert cell at correct row number
|
|
1347
|
+
rows[--rowNum].appendChild(cell);
|
|
1348
|
+
}
|
|
1349
|
+
else
|
|
1350
|
+
groups[groupId].colSpan++;
|
|
1351
|
+
|
|
1352
|
+
groupId = group.parentId;
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
// set css class first on left TH's
|
|
1358
|
+
setHeaderFirstChildClass(table);
|
|
1359
|
+
|
|
1360
|
+
// all dropzones must exist before we can bind events
|
|
1361
|
+
for (index = 0; index < _instance.columns.length; ++index)
|
|
1362
|
+
{
|
|
1363
|
+
column = _instance.columns[index];
|
|
1364
|
+
bindHeaderEvents(getColumnTableHeader(column.id), column, dragGhost);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
// hide columns under hidden group
|
|
1368
|
+
for (index = 0; index < _instance.columnGroups.length; ++index)
|
|
1369
|
+
{
|
|
1370
|
+
if (group.visible == false)
|
|
1371
|
+
setColumnGroupDisplay(_instance.columnGroups[index].id, false);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
if (_instance.enableFilterRow)
|
|
1375
|
+
createFilterRow(div);
|
|
1376
|
+
|
|
1377
|
+
function getDepthLevels()
|
|
1378
|
+
{
|
|
1379
|
+
var depth, groupId, column,
|
|
1380
|
+
_depthLevels = [0, {}];
|
|
1381
|
+
|
|
1382
|
+
for (var index = 0; index < _instance.columns.length; ++index)
|
|
1383
|
+
{
|
|
1384
|
+
column = _instance.columns[index];
|
|
1385
|
+
groupId = column.columnGroupId;
|
|
1386
|
+
depth = 1;
|
|
1387
|
+
_depthLevels[1][column.id] = depth;
|
|
1388
|
+
|
|
1389
|
+
while (!$lib.isEmpty(groupId))
|
|
1390
|
+
{
|
|
1391
|
+
++depth;
|
|
1392
|
+
|
|
1393
|
+
if (depth > _depthLevels[1][column.id])
|
|
1394
|
+
_depthLevels[1][column.id] = depth; // depth per column
|
|
1395
|
+
|
|
1396
|
+
groupId = _instance.columnGroups[getIndex(_instance.columnGroups, groupId)].parentId;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
if (depth > _depthLevels[0])
|
|
1400
|
+
_depthLevels[0] = depth; // total depth
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
return _depthLevels;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
function setHeaderFirstChildClass(table)
|
|
1408
|
+
{
|
|
1409
|
+
var tr = $lib(null, table, 'tr', true),
|
|
1410
|
+
stop, th;
|
|
1411
|
+
|
|
1412
|
+
while (tr && !stop)
|
|
1413
|
+
{
|
|
1414
|
+
th = tr.firstChild;
|
|
1415
|
+
$lib.addClass(th, 'first');
|
|
1416
|
+
stop = (th.rowSpan > 1);
|
|
1417
|
+
|
|
1418
|
+
tr = tr.nextSibling;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
function bindHeaderEvents(cell, column, dragGhost)
|
|
1423
|
+
{
|
|
1424
|
+
if (column.checkBox || column.expand)
|
|
1425
|
+
return;
|
|
1426
|
+
|
|
1427
|
+
var resizeHandle = $lib(_instance.cssClassResizeHandle || _classOption.RESIZE_HANDLE, cell, 'span', true),
|
|
1428
|
+
title = $lib(_instance.cssClassHeaderLabel || _classOption.HEADER_LABEL, cell, 'span', true),
|
|
1429
|
+
enableSorting = !column.disableSorting && _instance.columnSorting != _columnSortingOption.NONE;
|
|
1430
|
+
|
|
1431
|
+
if (_instance.resizableHeaders && resizeHandle)
|
|
1432
|
+
{
|
|
1433
|
+
$lib.resizable(cell, $base.static.initResizeSettings({
|
|
1434
|
+
resizeHandles: { 'e': resizeHandle },
|
|
1435
|
+
defaultHandles: false,
|
|
1436
|
+
onResizeStart: headerResizeStart,
|
|
1437
|
+
onResize: function (args) { $lib.defer(headerResize.bind(_instance, args)); },
|
|
1438
|
+
onResizeEnd: headerResizeEnd,
|
|
1439
|
+
}, _instance.headerResizeSettings));
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
if (enableSorting)
|
|
1443
|
+
{
|
|
1444
|
+
title.classList.add(_classOption.COLUMN_SORTING);
|
|
1445
|
+
$lib.on(title, 'click', sort, [column.id, null]);
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
if (_instance.draggableHeaders)
|
|
1449
|
+
{
|
|
1450
|
+
$lib.on(title, 'pointerdown', disableDrag, column.id);
|
|
1451
|
+
|
|
1452
|
+
if (resizeHandle)
|
|
1453
|
+
$lib.on(resizeHandle, 'pointerdown', disableDrag, column.id);
|
|
1454
|
+
|
|
1455
|
+
if (!$lib.has(document, 'pointerup', enableDrag))
|
|
1456
|
+
$lib.on(document, 'pointerup', enableDrag);
|
|
1457
|
+
|
|
1458
|
+
_headerDraggables[column.id] = $lib.draggable(cell, $base.static.initDragSettings({
|
|
1459
|
+
dragGhost: dragGhost,
|
|
1460
|
+
autoGhostSize: true,
|
|
1461
|
+
minDragX: 1,
|
|
1462
|
+
dragY: false,
|
|
1463
|
+
dropAcceptMode: 2,
|
|
1464
|
+
droppableClass: _instance.headerDragSettings.droppableClass || _classOption.DROPPABLE,
|
|
1465
|
+
dropZones: getHeaderDropZones(column),
|
|
1466
|
+
onDragStart: headerDragStart,
|
|
1467
|
+
onDroppable: function (args) { $lib.defer(headerDroppable.bind(_instance, args)); },
|
|
1468
|
+
onDroppableLeave: headerDroppableLeave,
|
|
1469
|
+
onDrop: headerDrop
|
|
1470
|
+
}, _instance.headerDragSettings));
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
function disableDrag(columnId)
|
|
1475
|
+
{
|
|
1476
|
+
_headerDraggables[columnId].disable();
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
function enableDrag()
|
|
1480
|
+
{
|
|
1481
|
+
_timerIds.push(setTimeout(function ()
|
|
1482
|
+
{
|
|
1483
|
+
$lib.each(_headerDraggables, function (item)
|
|
1484
|
+
{
|
|
1485
|
+
if (item.disabled)
|
|
1486
|
+
item.enable();
|
|
1487
|
+
});
|
|
1488
|
+
}, 0));
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
function getHeaderDropZones(column)
|
|
1492
|
+
{
|
|
1493
|
+
var index, col, dropZones = [];
|
|
1494
|
+
|
|
1495
|
+
for (index = 0; index < _instance.columns.length; ++index)
|
|
1496
|
+
{
|
|
1497
|
+
col = _instance.columns[index];
|
|
1498
|
+
|
|
1499
|
+
if (col.id != column.id && col.columnGroupId == column.columnGroupId)
|
|
1500
|
+
dropZones.push(getColumnTableHeader(col.id));
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
return dropZones;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
function getItemDropZones(item)
|
|
1507
|
+
{
|
|
1508
|
+
if (!_hasGroups)
|
|
1509
|
+
return _itemDropZones = $lib(null, _divContent, 'tr'); // without groups, all table-rows are droppable
|
|
1510
|
+
|
|
1511
|
+
var dropZones = [];
|
|
1512
|
+
|
|
1513
|
+
$lib.each(_instance.itemList, function (i)
|
|
1514
|
+
{
|
|
1515
|
+
if (i.parentId === item.parentId)
|
|
1516
|
+
dropZones.push(getItemRow(i.id));
|
|
1517
|
+
});
|
|
1518
|
+
|
|
1519
|
+
return dropZones;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
function createFilterRow(div)
|
|
1523
|
+
{
|
|
1524
|
+
var table = div.appendChild(document.createElement('div')).appendChild(document.createElement('table')),
|
|
1525
|
+
colgroup = table.appendChild(document.createElement('colgroup'));
|
|
1526
|
+
table.appendChild(document.createElement('tbody'));
|
|
1527
|
+
var cssClassCheckBox = _instance.cssClassCheckBox || _classOption.CHECKBOX,
|
|
1528
|
+
cssClassExpand = _instance.cssClassExpand || _classOption.EXPAND,
|
|
1529
|
+
cssClassHiddenColumn = _instance.cssClassHiddenColumn || _classOption.HIDDEN_COLUMN,
|
|
1530
|
+
cssClassFixedColumn = _instance.cssClassFixedColumn || _classOption.FIXED_COLUMN,
|
|
1531
|
+
row = table.insertRow(-1), cell, column, id, col,
|
|
1532
|
+
container, fixed;
|
|
1533
|
+
|
|
1534
|
+
_divFilter = table.parentNode;
|
|
1535
|
+
table.className = _instance.cssClassFilterRow || _classOption.FILTERROW;
|
|
1536
|
+
|
|
1537
|
+
$lib.on(_divFilter, 'keydown', filterKeydown, null, _instance);
|
|
1538
|
+
|
|
1539
|
+
for (var index = (showExpandColumn()) ? -1 : 0; index < _instance.columns.length; ++index)
|
|
1540
|
+
{
|
|
1541
|
+
fixed = (_instance.fixedColumns > 0 && index < _instance.fixedColumns);
|
|
1542
|
+
column = _instance.columns[index] || null;
|
|
1543
|
+
cell = row.appendChild(document.createElement('td'));
|
|
1544
|
+
cell.appendChild(document.createElement('div'));
|
|
1545
|
+
container = cell.firstChild.appendChild(document.createElement('div'));
|
|
1546
|
+
|
|
1547
|
+
// add col to colgroup
|
|
1548
|
+
col = colgroup.appendChild(document.createElement('col'));
|
|
1549
|
+
|
|
1550
|
+
if (index == -1)
|
|
1551
|
+
{
|
|
1552
|
+
$lib.addClass(cell, cssClassExpand);
|
|
1553
|
+
$lib.addClass(col, cssClassExpand);
|
|
1554
|
+
|
|
1555
|
+
if (fixed)
|
|
1556
|
+
$lib.addClass(cell, cssClassFixedColumn);
|
|
1557
|
+
|
|
1558
|
+
continue;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
id = $lib.format('{0}_FilterInput_{1}', _instance.id, column.id);
|
|
1562
|
+
|
|
1563
|
+
$lib.addClass(cell, column.cssClassHeader || _classOption.COLUMN);
|
|
1564
|
+
|
|
1565
|
+
if (fixed)
|
|
1566
|
+
$lib.addClass(cell, cssClassFixedColumn);
|
|
1567
|
+
|
|
1568
|
+
if (column.visible == false)
|
|
1569
|
+
{
|
|
1570
|
+
$lib.addClass(col, cssClassHiddenColumn);
|
|
1571
|
+
$lib.addClass(cell, cssClassHiddenColumn);
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
if (column.cssClassHeader)
|
|
1575
|
+
$lib.addClass(col, column.cssClassHeader);
|
|
1576
|
+
|
|
1577
|
+
if (!$lib.isEmpty(column.width))
|
|
1578
|
+
col.style.width = $lib.unit(column.width);
|
|
1579
|
+
|
|
1580
|
+
if (column.checkBox)
|
|
1581
|
+
{
|
|
1582
|
+
$lib.addClass(cell, cssClassCheckBox);
|
|
1583
|
+
$lib.addClass(col, cssClassCheckBox);
|
|
1584
|
+
}
|
|
1585
|
+
else if (!column.disableFilter)
|
|
1586
|
+
{
|
|
1587
|
+
var options = column.filterMenuOptions,
|
|
1588
|
+
range = (options & _filterMenuOptions.BETWEEN || options & _filterMenuOptions.NOTBETWEEN),
|
|
1589
|
+
rangeOnly = (options == _filterMenuOptions.BETWEEN + _filterMenuOptions.NOTBETWEEN ||
|
|
1590
|
+
options == _filterMenuOptions.BETWEEN || options == _filterMenuOptions.NOTBETWEEN),
|
|
1591
|
+
isSlider = column.filterInputType === _filterInputTypeOption.SLIDER,
|
|
1592
|
+
rangeContainer;
|
|
1593
|
+
|
|
1594
|
+
if (!options)
|
|
1595
|
+
options = getDefaultOptions(column);
|
|
1596
|
+
|
|
1597
|
+
if (range)
|
|
1598
|
+
rangeContainer = $lib.element(cell.firstChild, '', '', null, { "class": _classOption.FILTERRANGE });
|
|
1599
|
+
|
|
1600
|
+
if (_instance.hasTemplate('Filter_' + column.id) || _instance.hasTemplate('RangeFilter_' + column.id))
|
|
1601
|
+
{
|
|
1602
|
+
if (!rangeOnly)
|
|
1603
|
+
_instance.applyTemplate(container, 'Filter_' + column.id);
|
|
1604
|
+
|
|
1605
|
+
if (range)
|
|
1606
|
+
_instance.applyTemplate(rangeContainer, 'RangeFilter_' + column.id);
|
|
1607
|
+
}
|
|
1608
|
+
else
|
|
1609
|
+
{
|
|
1610
|
+
if (range && !isSlider)
|
|
1611
|
+
{
|
|
1612
|
+
var filterFrom = $lib.element(rangeContainer, '', 'label');
|
|
1613
|
+
filterFrom.className = _instance.cssClassFilterFrom || _classOption.FILTER_FROM;
|
|
1614
|
+
filterFrom.innerHTML = _instance.filterBetweenLabels[0] || '<b>From</b>';
|
|
1615
|
+
|
|
1616
|
+
var filterTo = $lib.element(rangeContainer, '', 'label');
|
|
1617
|
+
filterTo.className = _instance.cssClassFilterTo || _classOption.FILTER_TO;
|
|
1618
|
+
filterTo.innerHTML = _instance.filterBetweenLabels[1] || '<b>To</b>';
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
if (isSlider)
|
|
1622
|
+
{
|
|
1623
|
+
$lib.remove(rangeContainer);
|
|
1624
|
+
createSlider(column, id, options, container);
|
|
1625
|
+
}
|
|
1626
|
+
else
|
|
1627
|
+
{
|
|
1628
|
+
var fn;
|
|
1629
|
+
|
|
1630
|
+
if (!column.filterInputType)
|
|
1631
|
+
fn = createTextBox;
|
|
1632
|
+
else if (column.filterInputType == _filterInputTypeOption.NUMERICBOX)
|
|
1633
|
+
fn = createNumericBox;
|
|
1634
|
+
else if (column.filterInputType == _filterInputTypeOption.COMBOBOX)
|
|
1635
|
+
fn = createComboBox;
|
|
1636
|
+
else if (column.filterInputType == _filterInputTypeOption.DATEPICKER)
|
|
1637
|
+
fn = createDatePicker;
|
|
1638
|
+
else if (column.filterInputType == _filterInputTypeOption.TIMEPICKER)
|
|
1639
|
+
fn = createTimePicker;
|
|
1640
|
+
|
|
1641
|
+
if (!rangeOnly)
|
|
1642
|
+
fn(column, id, options, container);
|
|
1643
|
+
|
|
1644
|
+
if (range)
|
|
1645
|
+
{
|
|
1646
|
+
fn(column, id + '_From', options, filterFrom);
|
|
1647
|
+
fn(column, id + '_To', options, filterTo);
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
createFilterButton(column, options, cell.firstChild);
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
function filterKeydown(e)
|
|
1658
|
+
{
|
|
1659
|
+
if (e.key !== 'Enter')
|
|
1660
|
+
return;
|
|
1661
|
+
|
|
1662
|
+
let prefix = _instance.id + '_FilterInput_',
|
|
1663
|
+
match = null,
|
|
1664
|
+
el = e.target;
|
|
1665
|
+
|
|
1666
|
+
while (el)
|
|
1667
|
+
{
|
|
1668
|
+
if (el.id && el.id.indexOf(prefix) === 0)
|
|
1669
|
+
match = el; // keep overwriting, we want the outermost match, not the first one found
|
|
1670
|
+
|
|
1671
|
+
el = el.parentElement;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
if (!match)
|
|
1675
|
+
return; // not inside a filter input
|
|
1676
|
+
|
|
1677
|
+
let id = match.id.replace(/_From$|_To$/, ''); // range inputs are suffixed _From/_To, strip that first
|
|
1678
|
+
|
|
1679
|
+
e.preventDefault();
|
|
1680
|
+
triggerFilter(id.replace(prefix, ''));
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
function getDefaultOptions(column)
|
|
1684
|
+
{
|
|
1685
|
+
switch (column.filterInputType)
|
|
1686
|
+
{
|
|
1687
|
+
case _filterInputTypeOption.NUMERICBOX:
|
|
1688
|
+
case _filterInputTypeOption.DATEPICKER:
|
|
1689
|
+
case _filterInputTypeOption.TIMEPICKER:
|
|
1690
|
+
case _filterInputTypeOption.SLIDER:
|
|
1691
|
+
return _filterNumeric;
|
|
1692
|
+
case _filterInputTypeOption.COMBOBOX:
|
|
1693
|
+
case _filterInputTypeOption.TEXTBOX:
|
|
1694
|
+
return _filterText;
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
function createTextBox(column, id, options, container)
|
|
1699
|
+
{
|
|
1700
|
+
var input = container.appendChild(document.createElement('input'));
|
|
1701
|
+
|
|
1702
|
+
input.id = id;
|
|
1703
|
+
input.type = 'text';
|
|
1704
|
+
input.className = _instance.cssClassTextBox || _classOption.TEXTBOX;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
function createNumericBox(column, id, options, container)
|
|
1708
|
+
{
|
|
1709
|
+
var numericBox = $UI.createComponent(componyx.UI.NumericBox, { id: id, containerElement: container });
|
|
1710
|
+
|
|
1711
|
+
numericBox.clone($UI.store[column.filterInputId], _instance);
|
|
1712
|
+
numericBox.events.onPostRender.priorityAdd(function () { _instance.isReady.apply(_instance); }, null, true);
|
|
1713
|
+
numericBox.showing = true;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
function createComboBox(column, id, options, container)
|
|
1717
|
+
{
|
|
1718
|
+
var comboBox = $UI.createComponent(componyx.UI.ComboBox, { id: id, containerElement: container }),
|
|
1719
|
+
multiSelect = (options & _filterMenuOptions.IN || options & _filterMenuOptions.NOTIN);
|
|
1720
|
+
|
|
1721
|
+
comboBox.clone($UI.store[column.filterInputId], _instance);
|
|
1722
|
+
comboBox.multiSelect = multiSelect;
|
|
1723
|
+
comboBox.events.onPostRender.priorityAdd(function () { _instance.isReady.apply(_instance); }, null, true);
|
|
1724
|
+
comboBox.showing = true;
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
function createDatePicker(column, id, options, container)
|
|
1728
|
+
{
|
|
1729
|
+
var datePicker = $UI.createComponent(componyx.UI.DatePicker, { id: id, containerElement: container });
|
|
1730
|
+
|
|
1731
|
+
datePicker.clone($UI.store[column.filterInputId], _instance);
|
|
1732
|
+
datePicker.events.onPostRender.priorityAdd(function () { _instance.isReady.apply(_instance); }, null, true);
|
|
1733
|
+
datePicker.showing = true;
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
function createTimePicker(column, id, options, container)
|
|
1737
|
+
{
|
|
1738
|
+
var timePicker = $UI.createComponent(componyx.UI.TimePicker, { id: id, containerElement: container });
|
|
1739
|
+
|
|
1740
|
+
timePicker.clone($UI.store[column.filterInputId], _instance);
|
|
1741
|
+
timePicker.events.onPostRender.priorityAdd(function () { _instance.isReady.apply(_instance); }, null, true);
|
|
1742
|
+
timePicker.showing = true;
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
function createSlider(column, id, options, container)
|
|
1746
|
+
{
|
|
1747
|
+
var slider = $UI.createComponent(componyx.UI.Slider, { id: id, containerElement: container });
|
|
1748
|
+
|
|
1749
|
+
slider.clone($UI.store[column.filterInputId], _instance);
|
|
1750
|
+
slider.events.onPostRender.priorityAdd(function () { _instance.isReady.apply(_instance); }, null, true);
|
|
1751
|
+
slider.showing = true;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
function createFilterButton(column, options, container)
|
|
1755
|
+
{
|
|
1756
|
+
var id = $lib.format('{0}_FilterButton_{1}', _instance.id, column.id),
|
|
1757
|
+
button = $UI.createComponent(componyx.UI.Button, { id: id, containerElement: container }),
|
|
1758
|
+
singleOption = !options || (Math.log(options) / Math.log(2) % 1 == 0);
|
|
1759
|
+
|
|
1760
|
+
button.primary = button.transparentBorder = false;
|
|
1761
|
+
button.clone($UI.store[column.filterButtonId], _instance);
|
|
1762
|
+
button.hasIcon = true;
|
|
1763
|
+
button.cssClass = button.cssClass || _instance.cssClassFilterButton || _classOption.FILTER_BUTTON;
|
|
1764
|
+
button.command = filterCommand.bind(_instance, button);
|
|
1765
|
+
button.events.onPostRender.priorityAdd(function () { _instance.isReady.apply(_instance); }, null, true);
|
|
1766
|
+
button.showing = true;
|
|
1767
|
+
|
|
1768
|
+
if (!singleOption)
|
|
1769
|
+
{
|
|
1770
|
+
button.menuId = $lib.format('{0}_FilterMenu', _instance.id);
|
|
1771
|
+
button.menuItemId = column.id;
|
|
1772
|
+
|
|
1773
|
+
if (_tooltipManager)
|
|
1774
|
+
{
|
|
1775
|
+
button.tooltipManagerId = _tooltipManager.id;
|
|
1776
|
+
button.tooltipId = column.id + '_Filter';
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
createFilterMenu(column, options);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
function createFilterMenu(column, options)
|
|
1784
|
+
{
|
|
1785
|
+
var id = $lib.format('{0}_FilterMenu', _instance.id),
|
|
1786
|
+
menu = _filterMenu || $UI.createComponent(componyx.UI.Menu, { id: id, containerElement: _instance.element }),
|
|
1787
|
+
options = column.filterMenuOptions, rootItem = new componyx.UI.Menu.Item(), item, value;
|
|
1788
|
+
|
|
1789
|
+
if (!options)
|
|
1790
|
+
options = getDefaultOptions(column);
|
|
1791
|
+
|
|
1792
|
+
rootItem.id = column.id;
|
|
1793
|
+
menu.itemList.push(rootItem);
|
|
1794
|
+
|
|
1795
|
+
for (var key in _filterMenuOptions)
|
|
1796
|
+
{
|
|
1797
|
+
value = _filterMenuOptions[key];
|
|
1798
|
+
|
|
1799
|
+
if (options & value)
|
|
1800
|
+
{
|
|
1801
|
+
item = new componyx.UI.Menu.Item();
|
|
1802
|
+
item.id = $lib.format('{0}_{1}', rootItem.id, value);
|
|
1803
|
+
item.value = value;
|
|
1804
|
+
item.key = key;
|
|
1805
|
+
item.text = _instance.filterMenuLabels[key] || key;
|
|
1806
|
+
item.radioGroupId = column.id;
|
|
1807
|
+
item.type = componyx.UI.Menu.TypeOption.RADIOBUTTON;
|
|
1808
|
+
rootItem.itemList.push(item);
|
|
1809
|
+
|
|
1810
|
+
if ((!column.filterMenuSelectedOption && rootItem.itemList.length == 1) || column.filterMenuSelectedOption == _filterMenuOptions[key])
|
|
1811
|
+
{
|
|
1812
|
+
item.selected = true;
|
|
1813
|
+
|
|
1814
|
+
if (_tooltipManager)
|
|
1815
|
+
_tooltipManager.addTooltip(column.id + '_Filter', item.text);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
if (!_filterMenu)
|
|
1821
|
+
{
|
|
1822
|
+
_filterMenu = menu;
|
|
1823
|
+
menu.clone($UI.store[_instance.filterMenuId], _instance);
|
|
1824
|
+
menu.cssClass = menu.cssClass || _instance.cssClassFilterMenu || _classOption.FILTERMENU;
|
|
1825
|
+
menu.expandOnClick = true;
|
|
1826
|
+
menu.visibleRoot = false;
|
|
1827
|
+
menu.showing = true;
|
|
1828
|
+
menu.collapseAllOnSelect = true;
|
|
1829
|
+
menu.events.onPostRender.priorityAdd(() => { _instance.isReady.apply(_instance); }, null);
|
|
1830
|
+
menu.events.onItemExpand.priorityAdd(() => { _tooltipManager?.hideAllTooltips(); });
|
|
1831
|
+
menu.events.onItemSelect.priorityAdd(selectFilter);
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
toggleFilterView(column, rootItem.itemList[0]);
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
function createContent()
|
|
1838
|
+
{
|
|
1839
|
+
var table, column, colgroup, col, index,
|
|
1840
|
+
cssClassHiddenColumn = _instance.cssClassHiddenColumn || _classOption.HIDDEN_COLUMN,
|
|
1841
|
+
cssClassCheckBox = _instance.cssClassCheckBox || _classOption.CHECKBOX,
|
|
1842
|
+
cssClassExpand = _instance.cssClassExpand || _classOption.EXPAND;
|
|
1843
|
+
|
|
1844
|
+
_divContent = _instance.element.appendChild(document.createElement('div'));
|
|
1845
|
+
_divContent.className = _instance.cssClassContent || _classOption.CONTENT;
|
|
1846
|
+
|
|
1847
|
+
if (_instance.rowSelection > _rowSelectionOption.NONE)
|
|
1848
|
+
$lib.addClass(_divContent, _classOption.SELECTABLE);
|
|
1849
|
+
|
|
1850
|
+
if (!$lib.isEmpty(_instance.contentStyle))
|
|
1851
|
+
$lib.setStyle(_divContent, _instance.contentStyle);
|
|
1852
|
+
|
|
1853
|
+
if (!$lib.isEmpty(_instance.contentHeight))
|
|
1854
|
+
_divContent.style.height = $lib.unit(_instance.contentHeight);
|
|
1855
|
+
|
|
1856
|
+
table = _divContent.appendChild(document.createElement('table'));
|
|
1857
|
+
colgroup = table.appendChild(document.createElement('colgroup'));
|
|
1858
|
+
|
|
1859
|
+
table.appendChild(document.createElement('tbody'));
|
|
1860
|
+
|
|
1861
|
+
for (index = (showExpandColumn()) ? -1 : 0; index < _instance.columns.length; ++index)
|
|
1862
|
+
{
|
|
1863
|
+
col = colgroup.appendChild(document.createElement('col'));
|
|
1864
|
+
|
|
1865
|
+
if (index == -1)
|
|
1866
|
+
{
|
|
1867
|
+
$lib.addClass(col, cssClassExpand);
|
|
1868
|
+
continue;
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
column = _instance.columns[index];
|
|
1872
|
+
|
|
1873
|
+
if (column.visible == false)
|
|
1874
|
+
$lib.addClass(col, cssClassHiddenColumn);
|
|
1875
|
+
|
|
1876
|
+
if (column.checkBox)
|
|
1877
|
+
$lib.addClass(col, cssClassCheckBox);
|
|
1878
|
+
|
|
1879
|
+
if (column.cssClass)
|
|
1880
|
+
$lib.addClass(col, column.cssClass);
|
|
1881
|
+
|
|
1882
|
+
if (!$lib.isEmpty(column.width))
|
|
1883
|
+
col.style.width = $lib.unit(column.width);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
function createDataPager()
|
|
1888
|
+
{
|
|
1889
|
+
var id = _instance.id + '_Pager';
|
|
1890
|
+
_pager = $UI.createComponent(componyx.UI.DataPager, { id: id, containerElement: _instance.element });
|
|
1891
|
+
|
|
1892
|
+
_pager.visiblePages = 0;
|
|
1893
|
+
|
|
1894
|
+
_pager.clone($UI.store[_instance.dataPagerId], _instance);
|
|
1895
|
+
_pager.cssClass = _pager.cssClass || _instance.cssClassDataPager || _classOption.DATA_PAGER;
|
|
1896
|
+
_pager.events.onPostRender.priorityAdd(function () { _instance.isReady.apply(_instance); }, null);
|
|
1897
|
+
_pager.events.onIndexChange.priorityAdd(pageIndexChange, null);
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
function pageIndexChange(pager, args)
|
|
1901
|
+
{
|
|
1902
|
+
load(args.pageIndex);
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
function drawItemList()
|
|
1906
|
+
{
|
|
1907
|
+
var table = _divContent.firstChild, tbody = $lib(null, table, 'tbody', true);
|
|
1908
|
+
|
|
1909
|
+
_itemDropZones = null;
|
|
1910
|
+
|
|
1911
|
+
if (_divPreloader != null)
|
|
1912
|
+
_divPreloader.style.display = 'none';
|
|
1913
|
+
if (_divNoResult != null)
|
|
1914
|
+
_divNoResult.style.display = 'none';
|
|
1915
|
+
|
|
1916
|
+
// clear table data
|
|
1917
|
+
table.style.display = '';
|
|
1918
|
+
tbody.parentNode.replaceChild(document.createElement('tbody'), tbody);
|
|
1919
|
+
_hasGroups = false;
|
|
1920
|
+
_treeGroup = {};
|
|
1921
|
+
_itemDraggables = [];
|
|
1922
|
+
|
|
1923
|
+
for (var index = 0; index < _instance.itemList.length; ++index)
|
|
1924
|
+
{
|
|
1925
|
+
drawItem(table, _instance.itemList[index]);
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
_lastItem = null;
|
|
1929
|
+
_timerIds.push(setTimeout(initSelectable.bind(_instance, table), 0));
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
function drawItem(table, item, pos)
|
|
1933
|
+
{
|
|
1934
|
+
var rowIndex, index, column, cell, spanCheckBox, spanExpand, divGroupItem, spanGroupExpandIcon, group,
|
|
1935
|
+
cssClass = item.cssClass || _instance.cssClassItem || _classOption.ITEM,
|
|
1936
|
+
cssClassHiddenColumn = _instance.cssClassHiddenColumn || _classOption.HIDDEN_COLUMN,
|
|
1937
|
+
cssClassFixedColumn = _instance.cssClassFixedColumn || _classOption.FIXED_COLUMN,
|
|
1938
|
+
cssClassCheckBox = _instance.cssClassCheckBox || _classOption.CHECKBOX,
|
|
1939
|
+
cssClassExpand = _instance.cssClassExpand || _classOption.EXPAND,
|
|
1940
|
+
cssClassExpandIcon = _instance.cssClassExpandIcon || _classOption.EXPAND_ICON,
|
|
1941
|
+
cssClassGroupHead = _instance.cssClassGroupHead || _classOption.GROUP_HEAD,
|
|
1942
|
+
cssClassGroupItem = _instance.cssClassGroupItem || _classOption.GROUP_ITEM,
|
|
1943
|
+
cssClassGroupExpandIcon = _instance.cssClassExpandIcon || _classOption.EXPAND_ICON,
|
|
1944
|
+
itemIndent = item.groupIndent || _instance.groupIndent, fixed,
|
|
1945
|
+
tr = getItemRow(item.id);
|
|
1946
|
+
|
|
1947
|
+
// cache item
|
|
1948
|
+
_lastItem = item;
|
|
1949
|
+
|
|
1950
|
+
if (!tr)
|
|
1951
|
+
{
|
|
1952
|
+
tr = (pos) ? table.insertRow(pos) : table.insertRow(-1);
|
|
1953
|
+
rowIndex = tr.rowIndex;
|
|
1954
|
+
}
|
|
1955
|
+
else
|
|
1956
|
+
{
|
|
1957
|
+
rowIndex = tr.rowIndex;
|
|
1958
|
+
table.deleteRow(rowIndex);
|
|
1959
|
+
tr = table.insertRow(rowIndex);
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
tr.id = getItemId(item.id);
|
|
1963
|
+
|
|
1964
|
+
if (cssClass)
|
|
1965
|
+
tr.className = cssClass;
|
|
1966
|
+
|
|
1967
|
+
if (rowIndex % 2 != 0)
|
|
1968
|
+
$lib.addClass(tr, 'odd');
|
|
1969
|
+
|
|
1970
|
+
_instance.events.onPreRenderItem.fire(_instance, eventArgs(item, tr, null));
|
|
1971
|
+
|
|
1972
|
+
for (index = (showExpandColumn()) ? -1 : 0; index < _instance.columns.length; ++index)
|
|
1973
|
+
{
|
|
1974
|
+
column = _instance.columns[index] || null;
|
|
1975
|
+
cell = tr.appendChild(document.createElement('td'));
|
|
1976
|
+
fixed = (_instance.fixedColumns > 0 && index < _instance.fixedColumns);
|
|
1977
|
+
|
|
1978
|
+
if (index == -1)
|
|
1979
|
+
{
|
|
1980
|
+
if (item.expandable != false)
|
|
1981
|
+
{
|
|
1982
|
+
spanExpand = cell.appendChild(document.createElement('span'));
|
|
1983
|
+
spanExpand.className = cssClassExpandIcon;
|
|
1984
|
+
$lib.addClass(cell, cssClassExpand);
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
if (fixed)
|
|
1988
|
+
$lib.addClass(cell, cssClassFixedColumn);
|
|
1989
|
+
|
|
1990
|
+
continue;
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
$lib.addClass(cell, column.cssClass);
|
|
1994
|
+
|
|
1995
|
+
if (column.visible == false)
|
|
1996
|
+
$lib.addClass(cell, cssClassHiddenColumn);
|
|
1997
|
+
|
|
1998
|
+
if (fixed)
|
|
1999
|
+
$lib.addClass(cell, cssClassFixedColumn);
|
|
2000
|
+
|
|
2001
|
+
if (column.checkBox)
|
|
2002
|
+
{
|
|
2003
|
+
spanCheckBox = cell.appendChild(document.createElement('span'));
|
|
2004
|
+
spanCheckBox.className = cssClassCheckBox;
|
|
2005
|
+
|
|
2006
|
+
$lib.addClass(cell, cssClassCheckBox);
|
|
2007
|
+
|
|
2008
|
+
if (_instance.rowSelection == _rowSelectionOption.MULTI)
|
|
2009
|
+
{
|
|
2010
|
+
$lib.on(cell, 'click', function (itemId, e)
|
|
2011
|
+
{
|
|
2012
|
+
e.stopPropagation(); // skip the row click, which would replace the selection
|
|
2013
|
+
toggleSelectItem(itemId);
|
|
2014
|
+
}, item.id, _instance);
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
else
|
|
2018
|
+
{
|
|
2019
|
+
if ((item.isGroup || !$lib.isEmpty(item.parentId))
|
|
2020
|
+
&& (index == 0 || (index == 1 && _instance.columns[0].checkBox))) // first text column only
|
|
2021
|
+
{
|
|
2022
|
+
divGroupItem = cell.appendChild(document.createElement('div'));
|
|
2023
|
+
divGroupItem.className = cssClassGroupItem;
|
|
2024
|
+
|
|
2025
|
+
if (!$lib.isEmpty(item.parentId))
|
|
2026
|
+
{
|
|
2027
|
+
group = _treeGroup[item.parentId];
|
|
2028
|
+
|
|
2029
|
+
if (getIndex(group.items, item.id) == -1)
|
|
2030
|
+
group.items.push(item);
|
|
2031
|
+
|
|
2032
|
+
divGroupItem.style.marginLeft = $lib.unit(group.indent);
|
|
2033
|
+
|
|
2034
|
+
$lib.addClass(cell, cssClassGroupItem);
|
|
2035
|
+
|
|
2036
|
+
if (group.expanded === false)
|
|
2037
|
+
tr.style.display = 'none';
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
if (item.isGroup)
|
|
2041
|
+
{
|
|
2042
|
+
_hasGroups = true;
|
|
2043
|
+
|
|
2044
|
+
if (!_treeGroup[item.id])
|
|
2045
|
+
{
|
|
2046
|
+
_treeGroup[item.id] = {};
|
|
2047
|
+
_treeGroup[item.id].items = [];
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
_treeGroup[item.id].expanded = (group) ? group.expanded : item.groupExpanded;
|
|
2051
|
+
_treeGroup[item.id].indent = (group) ? group.indent + itemIndent : itemIndent; // set group indent
|
|
2052
|
+
|
|
2053
|
+
spanGroupExpandIcon = divGroupItem.appendChild(document.createElement('span'));
|
|
2054
|
+
$lib.addClass(cell, cssClassGroupHead);
|
|
2055
|
+
$lib.addClass(spanGroupExpandIcon, cssClassGroupExpandIcon);
|
|
2056
|
+
|
|
2057
|
+
if (item.groupExpanded)
|
|
2058
|
+
$lib.addClass(cell, _classOption.EXPANDED);
|
|
2059
|
+
|
|
2060
|
+
if (_treeGroup[item.id].items.length > 0)
|
|
2061
|
+
expandItemGroup(item.id, _treeGroup[item.id].expanded); // expand group when single item is re-rendered
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
_instance.applyTemplate(divGroupItem, 'Column_' + column.id, item);
|
|
2065
|
+
}
|
|
2066
|
+
else
|
|
2067
|
+
_instance.applyTemplate(cell, 'Column_' + column.id, item);
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
if (item.disabled)
|
|
2072
|
+
disableItem(item.id);
|
|
2073
|
+
|
|
2074
|
+
if (item.selected || _selectedItems[item.id])
|
|
2075
|
+
{
|
|
2076
|
+
_forceSelect = true;
|
|
2077
|
+
selectItem(item.id);
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
if (item.expanded)
|
|
2081
|
+
expandItem(item.id);
|
|
2082
|
+
|
|
2083
|
+
bindItemEvents(tr, spanExpand, (_instance.groupExpansion == _groupExpansionOption.ITEM) ? divGroupItem : spanGroupExpandIcon, item);
|
|
2084
|
+
|
|
2085
|
+
if (_instance.draggableItems && item.draggable)
|
|
2086
|
+
_timerIds.push(setTimeout(function () { initDraggable(item, tr); }.bind(_instance, item, tr), 0));
|
|
2087
|
+
|
|
2088
|
+
_instance.events.onPostRenderItem.fire(_instance, eventArgs(item, tr, null));
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
function bindItemEvents(tr, spanExpand, groupExpandEl, item)
|
|
2092
|
+
{
|
|
2093
|
+
$lib.on(tr, 'click', function (itemId)
|
|
2094
|
+
{
|
|
2095
|
+
if (_cancelSelect)
|
|
2096
|
+
return;
|
|
2097
|
+
|
|
2098
|
+
if (_instance.rowSelection == _rowSelectionOption.SINGLE)
|
|
2099
|
+
toggleSelectItem(itemId);
|
|
2100
|
+
|
|
2101
|
+
_instance.events.onItemClick.fire(_instance, eventArgs(loadItem(itemId), tr, null));
|
|
2102
|
+
}, item.id, _instance);
|
|
2103
|
+
|
|
2104
|
+
if (spanExpand) // expand item details
|
|
2105
|
+
{
|
|
2106
|
+
$lib.on(spanExpand.parentNode, 'pointerdown', _instance.cancelSelectClick);
|
|
2107
|
+
$lib.on(spanExpand.parentNode, 'click', toggleExpandItem, item.id, _instance);
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
if (groupExpandEl && item.isGroup && item.groupExpandable && _instance.groupExpansion != _groupExpansionOption.NONE) // expand item tree group
|
|
2111
|
+
{
|
|
2112
|
+
$lib.on(groupExpandEl, 'pointerdown', _instance.cancelSelectClick);
|
|
2113
|
+
$lib.on(groupExpandEl, 'click', expandItemGroup, [item.id, null], _instance);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
function initSelectable(table)
|
|
2118
|
+
{
|
|
2119
|
+
if (_instance.rowSelection == _rowSelectionOption.MULTI)
|
|
2120
|
+
{
|
|
2121
|
+
if (_selectable == null)
|
|
2122
|
+
{
|
|
2123
|
+
_selectable = $lib.selectable($base.static.initSelectSettings(
|
|
2124
|
+
{
|
|
2125
|
+
dragZone: _divContent,
|
|
2126
|
+
includeTags: 'tr',
|
|
2127
|
+
exclude: $lib('disabled', table, 'tr'),
|
|
2128
|
+
toggleClickSelect: (_instance.selectSettings.toggleClickSelect == false) ? false : true,
|
|
2129
|
+
selectMode: (_instance.draggableItems || (_instance.autoTouchConfig && $lib.touch)) ? 2 : '',
|
|
2130
|
+
onSelect: onSelect
|
|
2131
|
+
}, _instance.selectSettings));
|
|
2132
|
+
|
|
2133
|
+
$lib.on(_divContent, 'pointerdown', function (e)
|
|
2134
|
+
{
|
|
2135
|
+
var touch = (e.pointerType === 'touch');
|
|
2136
|
+
|
|
2137
|
+
// a touch tap behaves like a ctrl-click: add to the selection, tap again to remove
|
|
2138
|
+
_selectable.settings.appendClickSelect = touch || _instance.selectSettings.appendClickSelect;
|
|
2139
|
+
_selectable.settings.toggleClickSelect = touch || _instance.selectSettings.toggleClickSelect !== false;
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
else
|
|
2143
|
+
{
|
|
2144
|
+
_selectable.settings.exclude = $lib('disabled', table, 'tr');
|
|
2145
|
+
_selectable.update();
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
function initDraggable(item, tr)
|
|
2151
|
+
{
|
|
2152
|
+
var el = tr;
|
|
2153
|
+
|
|
2154
|
+
if ($lib.touch && _instance.autoTouchConfig)
|
|
2155
|
+
{
|
|
2156
|
+
el = tr.firstElementChild;
|
|
2157
|
+
el.setAttribute("style", "touch-action: none");
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
_itemDraggables.push($lib.draggable(el, $base.static.initDragSettings({
|
|
2161
|
+
dragGhost: createDragGhost(tr.parentNode, 'tr'),
|
|
2162
|
+
autoGhostSize: false,
|
|
2163
|
+
minDragY: 1,
|
|
2164
|
+
dragX: false,
|
|
2165
|
+
dropAcceptMode: 2,
|
|
2166
|
+
droppableClass: _instance.itemDragSettings.droppableClass || _classOption.DROPPABLE,
|
|
2167
|
+
dropZones: (!item.isGroup && $lib.isEmpty(item.parentId) && _itemDropZones) ? _itemDropZones : getItemDropZones(item),
|
|
2168
|
+
onDragStart: itemDragStart,
|
|
2169
|
+
onDragEnd: itemDragEnd,
|
|
2170
|
+
onDroppable: function (args) { $lib.defer(itemDroppable.bind(_instance, args)); },
|
|
2171
|
+
onDroppableLeave: itemDroppableLeave,
|
|
2172
|
+
onDrop: itemDrop
|
|
2173
|
+
}, _instance.itemDragSettings)));
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
function createDragGhost(container, nodeName)
|
|
2177
|
+
{
|
|
2178
|
+
var dragGhost = $lib.element(container, null, nodeName);
|
|
2179
|
+
dragGhost.className = _instance.cssClassDragGhost || _classOption.DRAG_GHOST;
|
|
2180
|
+
dragGhost.style.display = 'none';
|
|
2181
|
+
return dragGhost;
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
function detectViewportSize()
|
|
2185
|
+
{
|
|
2186
|
+
_timerIds.push(setTimeout(detect, 0));
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
function detect()
|
|
2190
|
+
{
|
|
2191
|
+
if (_instance.useViewportHeight)
|
|
2192
|
+
{
|
|
2193
|
+
var winSize = $lib.getWindowSize();
|
|
2194
|
+
|
|
2195
|
+
_divContent.style.height = 'auto';
|
|
2196
|
+
var pos = $lib.getPos(_divContent),
|
|
2197
|
+
availableHeight = (winSize.height - pos.top) - (_instance.viewportBottomOffset || 0);
|
|
2198
|
+
|
|
2199
|
+
if ((pos.top + pos.height) > availableHeight)
|
|
2200
|
+
_divContent.style.height = $lib.unit(availableHeight);
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
detectScrollX();
|
|
2204
|
+
detectScrollY();
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
function detectScrollX()
|
|
2208
|
+
{
|
|
2209
|
+
var overflow = $lib.styleValue(_divContent, 'overflow-x');
|
|
2210
|
+
|
|
2211
|
+
$lib.removeClass(_instance.element, _classOption.SCROLLABLE_X);
|
|
2212
|
+
|
|
2213
|
+
// because of a rounding bug within IE the inner width is used instead of the scrollWidth
|
|
2214
|
+
if ('hidden visible'.indexOf(overflow) > -1 || _divContent.firstChild.offsetWidth <= _divContent.clientWidth)
|
|
2215
|
+
return;
|
|
2216
|
+
|
|
2217
|
+
$lib.addClass(_instance.element, _classOption.SCROLLABLE_X);
|
|
2218
|
+
|
|
2219
|
+
if (!$lib.has(_divContent, 'scroll', scrollDelayed))
|
|
2220
|
+
$lib.on(_divContent, 'scroll', scrollDelayed);
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
function detectScrollY()
|
|
2224
|
+
{
|
|
2225
|
+
var overflow = $lib.styleValue(_divContent, 'overflow-y');
|
|
2226
|
+
|
|
2227
|
+
$lib.removeClass(_instance.element, _classOption.SCROLLABLE_Y);
|
|
2228
|
+
_divHeader.firstChild.style.paddingRight = '';
|
|
2229
|
+
|
|
2230
|
+
if (_divFilter)
|
|
2231
|
+
_divFilter.style.paddingRight = '';
|
|
2232
|
+
|
|
2233
|
+
// because of a rounding bug within IE the inner height is used instead of the scrollHeight
|
|
2234
|
+
if ('hidden visible'.indexOf(overflow) > -1 || (_divContent.firstChild.offsetHeight <= _divContent.clientHeight && overflow != 'scroll'))
|
|
2235
|
+
return;
|
|
2236
|
+
|
|
2237
|
+
$lib.addClass(_instance.element, _classOption.SCROLLABLE_Y);
|
|
2238
|
+
_divHeader.firstChild.style.paddingRight = $lib.unit(_scrollbarSize.width);
|
|
2239
|
+
|
|
2240
|
+
if (_divFilter)
|
|
2241
|
+
_divFilter.style.paddingRight = _divHeader.firstChild.style.paddingRight;
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
function scrollDelayed()
|
|
2245
|
+
{
|
|
2246
|
+
clearTimeout(_scrollTimerId);
|
|
2247
|
+
_scrollTimerId = setTimeout(function () { scroll(); }, 0);
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
function scroll()
|
|
2251
|
+
{
|
|
2252
|
+
var scrollLeft = _divContent.scrollLeft, table = _divHeader.firstChild,
|
|
2253
|
+
cssClassFixedColumn = _instance.cssClassFixedColumn || _classOption.FIXED_COLUMN;
|
|
2254
|
+
|
|
2255
|
+
if (_lastScrollLeft == scrollLeft)
|
|
2256
|
+
return;
|
|
2257
|
+
|
|
2258
|
+
table.style.marginLeft = $lib.unit(scrollLeft * -1);
|
|
2259
|
+
|
|
2260
|
+
if (_divFilter)
|
|
2261
|
+
_divFilter.firstChild.style.marginLeft = table.style.marginLeft;
|
|
2262
|
+
|
|
2263
|
+
if (_instance.fixedColumns > 0)
|
|
2264
|
+
{
|
|
2265
|
+
// update fixed column css rule with correct left position
|
|
2266
|
+
clearTimeout(_fixedColumnUpdateTimerId);
|
|
2267
|
+
_fixedColumnUpdateTimerId = setTimeout(function () { $lib.setCssRule(_fixedColumnStyleSheet, null, '#' + _instance.id + ' .' + cssClassFixedColumn, 'left:' + scrollLeft + 'px;'); }, _instance.fixedColumnScrollUpdate);
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
_lastScrollLeft = scrollLeft;
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
function showPreloader()
|
|
2274
|
+
{
|
|
2275
|
+
hideChildren(_divContent);
|
|
2276
|
+
|
|
2277
|
+
if (_divPreloader != null)
|
|
2278
|
+
_divPreloader.style.display = '';
|
|
2279
|
+
else if (_instance.hasTemplate('Preloader'))
|
|
2280
|
+
{
|
|
2281
|
+
_divPreloader = _divContent.appendChild(document.createElement('div'));
|
|
2282
|
+
_divPreloader.className = _instance.cssClassPreloader || _classOption.PRELOADER;
|
|
2283
|
+
_instance.applyTemplate(_divPreloader, 'Preloader');
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
function showItemPreloader(cell)
|
|
2288
|
+
{
|
|
2289
|
+
if (_instance.hasTemplate('ItemPreloader'))
|
|
2290
|
+
{
|
|
2291
|
+
var divPreloader = cell.appendChild(document.createElement('div'));
|
|
2292
|
+
divPreloader.className = _instance.cssClassPreloader || _classOption.PRELOADER;
|
|
2293
|
+
_instance.applyTemplate(divPreloader, 'ItemPreloader');
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
function showNoResult()
|
|
2298
|
+
{
|
|
2299
|
+
hideChildren(_divContent);
|
|
2300
|
+
|
|
2301
|
+
if (_divNoResult != null)
|
|
2302
|
+
_divNoResult.style.display = '';
|
|
2303
|
+
else if (_instance.hasTemplate('NoResult'))
|
|
2304
|
+
{
|
|
2305
|
+
_divNoResult = _divContent.appendChild(document.createElement('div'));
|
|
2306
|
+
_divNoResult.className = _instance.cssClassNoResult || _classOption.NORESULT;
|
|
2307
|
+
_instance.applyTemplate(_divNoResult, 'NoResult');
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
function hideChildren(container)
|
|
2312
|
+
{
|
|
2313
|
+
var childs = $lib.children(container);
|
|
2314
|
+
|
|
2315
|
+
$lib.each(childs, function (el)
|
|
2316
|
+
{
|
|
2317
|
+
el.style.display = 'none';
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
function selectFilter(menu, args)
|
|
2322
|
+
{
|
|
2323
|
+
var item = args.item,
|
|
2324
|
+
key = item.key,
|
|
2325
|
+
column = _instance.columns[getIndex(_instance.columns, item.radioGroupId)];
|
|
2326
|
+
|
|
2327
|
+
toggleFilterView(column, item);
|
|
2328
|
+
|
|
2329
|
+
if (_tooltipManager)
|
|
2330
|
+
{
|
|
2331
|
+
if (_tooltipManager.getBox())
|
|
2332
|
+
_tooltipManager.getBox().hide(true);
|
|
2333
|
+
|
|
2334
|
+
_tooltipManager.addTooltip(column.id + '_Filter', _instance.filterMenuLabels[key] || key);
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
function toggleFilterView(column, item)
|
|
2339
|
+
{
|
|
2340
|
+
var value = item.value,
|
|
2341
|
+
isRange = (value == _filterMenuOptions.BETWEEN || value == _filterMenuOptions.NOTBETWEEN);
|
|
2342
|
+
|
|
2343
|
+
if (column.filterInputType === _filterInputTypeOption.SLIDER)
|
|
2344
|
+
{
|
|
2345
|
+
var slider = $UI.store[$lib.format('{0}_FilterInput_{1}', _instance.id, column.id)],
|
|
2346
|
+
curValue = slider.getValue(),
|
|
2347
|
+
isArray = $lib.isArray(curValue);
|
|
2348
|
+
|
|
2349
|
+
if ((isArray && !isRange) || (!isArray && isRange))
|
|
2350
|
+
{
|
|
2351
|
+
if (isRange)
|
|
2352
|
+
slider.value = curValue;
|
|
2353
|
+
else
|
|
2354
|
+
slider.value = curValue[1];
|
|
2355
|
+
|
|
2356
|
+
slider.range = isRange;
|
|
2357
|
+
slider.render();
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
return;
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
var div = getFilterCell(column.id).firstElementChild,
|
|
2364
|
+
container = div.firstElementChild,
|
|
2365
|
+
rangeContainer = $lib(_classOption.FILTERRANGE, div, 'div', true);
|
|
2366
|
+
|
|
2367
|
+
if (!rangeContainer)
|
|
2368
|
+
return;
|
|
2369
|
+
|
|
2370
|
+
|
|
2371
|
+
container.style.display = (isRange) ? 'none' : '';
|
|
2372
|
+
rangeContainer.style.display = (isRange) ? '' : 'none';
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
function filterCommand(button)
|
|
2376
|
+
{
|
|
2377
|
+
var columnId = button.id.replace(_instance.id + '_FilterButton_', '');
|
|
2378
|
+
triggerFilter(columnId);
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
function triggerFilter(columnId)
|
|
2382
|
+
{
|
|
2383
|
+
var column = _instance.columns[getIndex(_instance.columns, columnId)],
|
|
2384
|
+
selOption = column.filterMenuSelectedOption || 1,
|
|
2385
|
+
type = selOption,
|
|
2386
|
+
item;
|
|
2387
|
+
|
|
2388
|
+
if (_filterMenu)
|
|
2389
|
+
{
|
|
2390
|
+
item = _filterMenu.getSelectedItem(columnId);
|
|
2391
|
+
type = (item) ? _filterMenuOptions[item.key] : selOption;
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
filter(columnId, getFilterValue(columnId), type);
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
function filter(columnId, value, type)
|
|
2398
|
+
{
|
|
2399
|
+
setColumnFilter(columnId, value, type);
|
|
2400
|
+
load();
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
function setColumnFilter(columnId, value, type)
|
|
2404
|
+
{
|
|
2405
|
+
if ((type != _filterMenuOptions.EMPTY && type != _filterMenuOptions.NOTEMPTY) && $lib.isEmpty(value) || ($lib.isArray(value) && $lib.isEmpty(value.join(''))))
|
|
2406
|
+
delete _filter[columnId];
|
|
2407
|
+
else
|
|
2408
|
+
{
|
|
2409
|
+
_filter[columnId] = {};
|
|
2410
|
+
_filter[columnId].type = _filterMenuOptions.getName(type);
|
|
2411
|
+
_filter[columnId].value = value;
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
function getFilterValue(columnId)
|
|
2416
|
+
{
|
|
2417
|
+
var index = getIndex(_instance.columns, columnId),
|
|
2418
|
+
column = _instance.columns[index],
|
|
2419
|
+
cell = getFilterCell(null, index),
|
|
2420
|
+
columnFilter = [],
|
|
2421
|
+
id = $lib.format('{0}_FilterInput_{1}', _instance.id, column.id),
|
|
2422
|
+
idFrom = id + '_From', idTo = id + '_To',
|
|
2423
|
+
input, fn = 'getValue';
|
|
2424
|
+
|
|
2425
|
+
if (!column.filterInputType)
|
|
2426
|
+
{
|
|
2427
|
+
input = $lib('#' + id);
|
|
2428
|
+
|
|
2429
|
+
if (cell.firstChild.style.display != 'none')
|
|
2430
|
+
{
|
|
2431
|
+
appendFilter(input.value);
|
|
2432
|
+
}
|
|
2433
|
+
else
|
|
2434
|
+
{
|
|
2435
|
+
appendFilter($lib('#' + idFrom).value);
|
|
2436
|
+
appendFilter($lib('#' + idTo).value);
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
else
|
|
2440
|
+
{
|
|
2441
|
+
if (cell.firstChild.style.display != 'none')
|
|
2442
|
+
{
|
|
2443
|
+
appendFilter($UI.store[id][fn]());
|
|
2444
|
+
}
|
|
2445
|
+
else
|
|
2446
|
+
{
|
|
2447
|
+
appendFilter($UI.store[idFrom][fn]());
|
|
2448
|
+
appendFilter($UI.store[idTo][fn]());
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
return columnFilter;
|
|
2453
|
+
|
|
2454
|
+
function appendFilter(value)
|
|
2455
|
+
{
|
|
2456
|
+
if (!$lib.isEmpty(value))
|
|
2457
|
+
columnFilter = ($lib.isArray(value)) ? columnFilter.concat(value.slice(0)) : columnFilter.concat([value]);
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
function setFilterValue(columnId, value)
|
|
2462
|
+
{
|
|
2463
|
+
var index = getIndex(_instance.columns, columnId),
|
|
2464
|
+
column = _instance.columns[index],
|
|
2465
|
+
cell = getFilterCell(null, index),
|
|
2466
|
+
id = $lib.format('{0}_FilterInput_{1}', _instance.id, column.id),
|
|
2467
|
+
idFrom = id + '_From', idTo = id + '_To',
|
|
2468
|
+
input;
|
|
2469
|
+
|
|
2470
|
+
if (!column.filterInputType)
|
|
2471
|
+
{
|
|
2472
|
+
input = $lib('#' + id);
|
|
2473
|
+
|
|
2474
|
+
if (cell.firstChild.style.display != 'none')
|
|
2475
|
+
{
|
|
2476
|
+
input.value = value;
|
|
2477
|
+
}
|
|
2478
|
+
else
|
|
2479
|
+
{
|
|
2480
|
+
$lib('#' + idFrom).value = value;
|
|
2481
|
+
$lib('#' + idTo).value = value;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
else
|
|
2485
|
+
{
|
|
2486
|
+
if (cell.firstChild.style.display != 'none')
|
|
2487
|
+
{
|
|
2488
|
+
setValue(id);
|
|
2489
|
+
}
|
|
2490
|
+
else
|
|
2491
|
+
{
|
|
2492
|
+
setValue(idFrom);
|
|
2493
|
+
setValue(idTo);
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
function setValue(id)
|
|
2498
|
+
{
|
|
2499
|
+
if (column.filterInputType == _filterInputTypeOption.COMBOBOX)
|
|
2500
|
+
{
|
|
2501
|
+
$UI.store[id].clearSelection();
|
|
2502
|
+
$UI.store[id].selectedItems($lib.isArray(value) ? value : [value]);
|
|
2503
|
+
}
|
|
2504
|
+
else
|
|
2505
|
+
{
|
|
2506
|
+
$UI.store[id].setValue(value);
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
function selectAll(spanSelectAll)
|
|
2512
|
+
{
|
|
2513
|
+
if ($lib.hasClass(spanSelectAll, _classOption.SELECTED))
|
|
2514
|
+
{
|
|
2515
|
+
$lib.removeClass(spanSelectAll, _classOption.SELECTED);
|
|
2516
|
+
_selectable.deselect();
|
|
2517
|
+
}
|
|
2518
|
+
else
|
|
2519
|
+
{
|
|
2520
|
+
$lib.addClass(spanSelectAll, _classOption.SELECTED);
|
|
2521
|
+
_selectable.select();
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
function sort(columnId, order)
|
|
2526
|
+
{
|
|
2527
|
+
setColumnSortOrder(columnId, order);
|
|
2528
|
+
_instance.events.onColumnSort.fire(_instance, { columnId: columnId, order: _sort[columnId] });
|
|
2529
|
+
|
|
2530
|
+
load();
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
function setColumnSortOrder(columnId, order)
|
|
2534
|
+
{
|
|
2535
|
+
var th = getColumnTableHeader(columnId),
|
|
2536
|
+
both = _classOption.SORTASC + ' ' + _classOption.SORTDESC;
|
|
2537
|
+
|
|
2538
|
+
if (!$lib.isEmpty(order))
|
|
2539
|
+
{
|
|
2540
|
+
$lib.removeClass(th, both);
|
|
2541
|
+
|
|
2542
|
+
if (order == _sortOrderOption.ASC)
|
|
2543
|
+
$lib.addClass(th, _classOption.SORTASC);
|
|
2544
|
+
else if (order == _sortOrderOption.DESC)
|
|
2545
|
+
$lib.addClass(th, _classOption.SORTDESC);
|
|
2546
|
+
}
|
|
2547
|
+
else
|
|
2548
|
+
{
|
|
2549
|
+
if ($lib.hasClass(th, _classOption.SORTASC))
|
|
2550
|
+
{
|
|
2551
|
+
$lib.removeClass(th, _classOption.SORTASC);
|
|
2552
|
+
$lib.addClass(th, _classOption.SORTDESC);
|
|
2553
|
+
}
|
|
2554
|
+
else if ($lib.hasClass(th, _classOption.SORTDESC))
|
|
2555
|
+
$lib.removeClass(th, _classOption.SORTDESC);
|
|
2556
|
+
else
|
|
2557
|
+
$lib.addClass(th, _classOption.SORTASC);
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
if (_instance.columnSorting != _columnSortingOption.MULTI)
|
|
2561
|
+
{
|
|
2562
|
+
$lib.each(_sort, function (order, key)
|
|
2563
|
+
{
|
|
2564
|
+
if (key != columnId)
|
|
2565
|
+
$lib.removeClass(getColumnTableHeader(key), both);
|
|
2566
|
+
});
|
|
2567
|
+
|
|
2568
|
+
_sort = {};
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
if ($lib.hasClass(th, _classOption.SORTASC))
|
|
2572
|
+
_sort[columnId] = _sortOrderOption.ASC;
|
|
2573
|
+
else if ($lib.hasClass(th, _classOption.SORTDESC))
|
|
2574
|
+
_sort[columnId] = _sortOrderOption.DESC;
|
|
2575
|
+
else if (columnId in _sort)
|
|
2576
|
+
delete _sort[columnId];
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
function headerDragStart(args)
|
|
2580
|
+
{
|
|
2581
|
+
args.settings.dragGhost.innerHTML = args.element.firstChild.textContent;
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
function headerDroppable(args)
|
|
2585
|
+
{
|
|
2586
|
+
var dropZone = args.dropZone,
|
|
2587
|
+
center = (args.dropZonePos.left + (dropZone.offsetWidth / 2)),
|
|
2588
|
+
cssLeft = _classOption.LEFT,
|
|
2589
|
+
cssRight = _classOption.RIGHT,
|
|
2590
|
+
scroll = $lib.getScrollPosition(),
|
|
2591
|
+
clientX = $lib.clientX($lib.event) + scroll.scrollLeft;
|
|
2592
|
+
|
|
2593
|
+
$lib.removeClass(dropZone, cssLeft + ' ' + cssRight);
|
|
2594
|
+
|
|
2595
|
+
if (clientX <= center)
|
|
2596
|
+
{
|
|
2597
|
+
$lib.addClass(dropZone, cssLeft);
|
|
2598
|
+
}
|
|
2599
|
+
else
|
|
2600
|
+
{
|
|
2601
|
+
$lib.addClass(dropZone, cssRight);
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
function headerDroppableLeave(args)
|
|
2606
|
+
{
|
|
2607
|
+
$lib.removeClass(args.dropZone, _classOption.LEFT + ' ' + _classOption.RIGHT);
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
function headerDrop(args)
|
|
2611
|
+
{
|
|
2612
|
+
var column,
|
|
2613
|
+
sourceId = args.element.id.replace(_instance.id + '_h_', ''),
|
|
2614
|
+
targetId = args.dropZone.id.replace(_instance.id + '_h_', ''),
|
|
2615
|
+
sourceIndex = getIndex(_instance.columns, sourceId),
|
|
2616
|
+
targetIndex = getIndex(_instance.columns, targetId),
|
|
2617
|
+
right = $lib.hasClass(args.dropZone, _classOption.RIGHT),
|
|
2618
|
+
tables = $lib(null, _divHeader, 'table'),
|
|
2619
|
+
tr = $lib(null, _divContent, 'tr', true);
|
|
2620
|
+
|
|
2621
|
+
$lib.removeClass(args.dropZone, _classOption.LEFT + ' ' + _classOption.RIGHT);
|
|
2622
|
+
|
|
2623
|
+
// clear element drop position
|
|
2624
|
+
$lib.updateStyle(args.element.style, 'position:;left:;top:;');
|
|
2625
|
+
|
|
2626
|
+
if (right)
|
|
2627
|
+
++targetIndex;
|
|
2628
|
+
|
|
2629
|
+
if (sourceIndex == targetIndex)
|
|
2630
|
+
return;
|
|
2631
|
+
|
|
2632
|
+
// change header column order
|
|
2633
|
+
changeHeaderColumnOrder(tables[0], sourceIndex, sourceId, targetIndex, targetId, right);
|
|
2634
|
+
|
|
2635
|
+
if (_instance.enableFilterRow)
|
|
2636
|
+
{
|
|
2637
|
+
// change filter row column order
|
|
2638
|
+
changeColumnOrder($lib(null, tables[1], 'tr', true), sourceIndex, targetIndex);
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
if (!_loading && tr)
|
|
2642
|
+
{
|
|
2643
|
+
// change column order
|
|
2644
|
+
changeColumnOrder(tr, sourceIndex, targetIndex);
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
// remove column at source index
|
|
2648
|
+
column = _instance.columns.splice(sourceIndex, 1)[0];
|
|
2649
|
+
|
|
2650
|
+
if (targetIndex > sourceIndex)
|
|
2651
|
+
--targetIndex;
|
|
2652
|
+
|
|
2653
|
+
_instance.columns.splice(targetIndex, 0, column); // add column to target index
|
|
2654
|
+
_instance.events.onColumnOrderChange.fire(_instance, { sourceIndex: sourceIndex, targetIndex: targetIndex });
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
function headerResizeStart(args)
|
|
2658
|
+
{
|
|
2659
|
+
storeTableData(args);
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
function headerResizeEnd(args)
|
|
2663
|
+
{
|
|
2664
|
+
detectScrollX();
|
|
2665
|
+
_instance.events.onColumnResize.fire(_instance, { columnIndex: _tableData.columnIndex, element: args.element });
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
function headerResize(args)
|
|
2669
|
+
{
|
|
2670
|
+
var index = _tableData.columnIndex,
|
|
2671
|
+
width = args.element.style.width, change, remainder = 0;
|
|
2672
|
+
|
|
2673
|
+
updateColumnWidth(index, width);
|
|
2674
|
+
|
|
2675
|
+
if (_instance.preserveTotalWidth && _tableData.columnDistribution.length > 0) // divide the width difference over columns
|
|
2676
|
+
{
|
|
2677
|
+
change = (_tableData.columnStartWidth - parseFloat(width)) / _tableData.columnDistribution.length;
|
|
2678
|
+
|
|
2679
|
+
$lib.each(_tableData.columnDistribution, function (colData)
|
|
2680
|
+
{
|
|
2681
|
+
width = (colData.width + change) + remainder;
|
|
2682
|
+
|
|
2683
|
+
if (width >= 0)
|
|
2684
|
+
updateColumnWidth(colData.index, $lib.unit(width));
|
|
2685
|
+
else
|
|
2686
|
+
{
|
|
2687
|
+
updateColumnWidth(colData.index, '0px');
|
|
2688
|
+
remainder = width;
|
|
2689
|
+
}
|
|
2690
|
+
});
|
|
2691
|
+
}
|
|
2692
|
+
else if (!_instance.preserveTotalWidth)
|
|
2693
|
+
{
|
|
2694
|
+
change = (parseFloat(width) - _tableData.columnStartWidth);
|
|
2695
|
+
_instance.element.style.width = $lib.unit(_tableData.totalWidth + change);
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
function updateColumnWidth(index, width)
|
|
2700
|
+
{
|
|
2701
|
+
// update col elements for fixed table-layout
|
|
2702
|
+
_tableData.header[index].style.width = _tableData.content[index].style.width = width;
|
|
2703
|
+
|
|
2704
|
+
if (_tableData.filter != null)
|
|
2705
|
+
_tableData.filter[index].style.width = width;
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
function changeHeaderColumnOrder(table, sourceIndex, sourceId, targetIndex, targetId, right)
|
|
2709
|
+
{
|
|
2710
|
+
var tr = $lib(null, table, 'tr')[_depthLevels[1][sourceId] - 1],
|
|
2711
|
+
sourceElement = getColumnTableHeader(sourceId),
|
|
2712
|
+
targetElement = getColumnTableHeader(targetId);
|
|
2713
|
+
|
|
2714
|
+
changeOrder($lib(null, table, 'colgroup', true), sourceIndex, targetIndex);
|
|
2715
|
+
|
|
2716
|
+
if (right)
|
|
2717
|
+
targetElement = targetElement.nextSibling || null;
|
|
2718
|
+
|
|
2719
|
+
if (targetElement)
|
|
2720
|
+
tr.insertBefore(sourceElement, targetElement);
|
|
2721
|
+
else
|
|
2722
|
+
tr.appendChild(sourceElement);
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2725
|
+
function changeColumnOrder(tr, sourceIndex, targetIndex)
|
|
2726
|
+
{
|
|
2727
|
+
var expandIndex = (showExpandColumn()) ? 1 : 0,
|
|
2728
|
+
cellCount = _instance.columns.length + expandIndex;
|
|
2729
|
+
|
|
2730
|
+
changeOrder($lib(null, tr.parentNode.parentNode, 'colgroup', true), sourceIndex, targetIndex);
|
|
2731
|
+
|
|
2732
|
+
while (tr)
|
|
2733
|
+
{
|
|
2734
|
+
if (tr.childNodes.length == cellCount)
|
|
2735
|
+
changeOrder(tr, sourceIndex, targetIndex);
|
|
2736
|
+
|
|
2737
|
+
tr = tr.nextSibling;
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
function changeOrder(parent, sourceIndex, targetIndex)
|
|
2742
|
+
{
|
|
2743
|
+
sourceIndex = getCellIndex(sourceIndex);
|
|
2744
|
+
targetIndex = getCellIndex(targetIndex);
|
|
2745
|
+
|
|
2746
|
+
var childNodes = parent.childNodes,
|
|
2747
|
+
append = (targetIndex >= childNodes.length);
|
|
2748
|
+
|
|
2749
|
+
if (append)
|
|
2750
|
+
parent.appendChild(childNodes[sourceIndex]);
|
|
2751
|
+
else
|
|
2752
|
+
parent.insertBefore(childNodes[sourceIndex], childNodes[targetIndex]);
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
function itemDragStart(args)
|
|
2756
|
+
{
|
|
2757
|
+
var tr = getTableRow(args.element),
|
|
2758
|
+
el = tr.cloneNode(true),
|
|
2759
|
+
dragGhost = args.settings.dragGhost,
|
|
2760
|
+
childNodes = el.childNodes,
|
|
2761
|
+
node = tr.firstChild;
|
|
2762
|
+
|
|
2763
|
+
if (dragGhost.parentNode != tr.parentNode)
|
|
2764
|
+
tr.parentNode.appendChild(dragGhost);
|
|
2765
|
+
|
|
2766
|
+
dragGhost.innerHTML = '';
|
|
2767
|
+
|
|
2768
|
+
while (node)
|
|
2769
|
+
{
|
|
2770
|
+
var td = childNodes[0];
|
|
2771
|
+
td.style.width = $lib.unit(node.offsetWidth);
|
|
2772
|
+
dragGhost.appendChild(td);
|
|
2773
|
+
node = node.nextSibling;
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
$lib.addClass(tr, _classOption.DRAG);
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
function itemDragEnd(args)
|
|
2780
|
+
{
|
|
2781
|
+
$lib.removeClass(getTableRow(args.element), _classOption.DRAG);
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
function itemDroppable(args)
|
|
2785
|
+
{
|
|
2786
|
+
var dropZone = args.dropZone,
|
|
2787
|
+
center = (args.dropZonePos.top + (dropZone.offsetHeight / 2)),
|
|
2788
|
+
cssTop = _classOption.TOP,
|
|
2789
|
+
cssBottom = _classOption.BOTTOM,
|
|
2790
|
+
scroll = $lib.getScrollPosition(),
|
|
2791
|
+
clientY = $lib.clientY($lib.event) + scroll.scrollTop;
|
|
2792
|
+
|
|
2793
|
+
$lib.removeClass(dropZone, cssTop + ' ' + cssBottom);
|
|
2794
|
+
|
|
2795
|
+
if (clientY <= center)
|
|
2796
|
+
{
|
|
2797
|
+
$lib.addClass(dropZone, cssTop);
|
|
2798
|
+
}
|
|
2799
|
+
else
|
|
2800
|
+
{
|
|
2801
|
+
$lib.addClass(dropZone, cssBottom);
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2805
|
+
function itemDroppableLeave(args)
|
|
2806
|
+
{
|
|
2807
|
+
clearDropZoneCSS(args.dropZone);
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2810
|
+
function itemDrop(args)
|
|
2811
|
+
{
|
|
2812
|
+
var itemList = _instance.itemList,
|
|
2813
|
+
dropZone = args.dropZone,
|
|
2814
|
+
tr = getTableRow(args.element),
|
|
2815
|
+
bottom = $lib.hasClass(dropZone, _classOption.BOTTOM),
|
|
2816
|
+
index = $lib.indexOf(args.settings.dropZones, tr),
|
|
2817
|
+
targetIndex = $lib.indexOf(args.settings.dropZones, dropZone);
|
|
2818
|
+
|
|
2819
|
+
if (Math.abs(targetIndex - index) > 1 || (targetIndex > index && bottom) || (targetIndex < index && !bottom))
|
|
2820
|
+
{
|
|
2821
|
+
var nextRow = (bottom) ? dropZone.nextElementSibling : dropZone,
|
|
2822
|
+
item = loadItem(tr.id.replace(_instance.id + '_', '')),
|
|
2823
|
+
targetItem = loadItem(dropZone.id.replace(_instance.id + '_', '')),
|
|
2824
|
+
expanded = [],
|
|
2825
|
+
items = [item];
|
|
2826
|
+
|
|
2827
|
+
index = getIndex(itemList, item.id);
|
|
2828
|
+
|
|
2829
|
+
if (item.isGroup)
|
|
2830
|
+
{
|
|
2831
|
+
items = items.concat(getItemsInGroup(item.id));
|
|
2832
|
+
collapseItems(items, expanded);
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
if (targetItem.isGroup && bottom)
|
|
2836
|
+
{
|
|
2837
|
+
var groupItems = getItemsInGroup(targetItem.id);
|
|
2838
|
+
|
|
2839
|
+
collapseItems([targetItem].concat(groupItems), expanded);
|
|
2840
|
+
targetIndex = getIndex(itemList, groupItems[groupItems.length - 1].id) + 1;
|
|
2841
|
+
nextRow = (!itemList[targetIndex]) ? null : getItemRow(itemList[targetIndex].id);
|
|
2842
|
+
}
|
|
2843
|
+
else
|
|
2844
|
+
targetIndex = getIndex(itemList, targetItem.id);
|
|
2845
|
+
|
|
2846
|
+
if (!targetItem.isGroup && bottom)
|
|
2847
|
+
++targetIndex;
|
|
2848
|
+
|
|
2849
|
+
var resultIndex = $lib.move(itemList, index, targetIndex, items.length); // move items
|
|
2850
|
+
|
|
2851
|
+
// move table-rows
|
|
2852
|
+
$lib.each(items, function (i)
|
|
2853
|
+
{
|
|
2854
|
+
var tr = getItemRow(i.id);
|
|
2855
|
+
tr.parentNode.insertBefore(tr, nextRow);
|
|
2856
|
+
});
|
|
2857
|
+
|
|
2858
|
+
// expand items that where expanded before the move
|
|
2859
|
+
$lib.each(expanded, function (id)
|
|
2860
|
+
{
|
|
2861
|
+
expandItem(id);
|
|
2862
|
+
});
|
|
2863
|
+
|
|
2864
|
+
updateItemDropZones((!_hasGroups) ? getItemDropZones() : null);
|
|
2865
|
+
_instance.events.onItemOrderChange.fire(_instance, { items: items, fromIndex: index, toIndex: targetIndex, resultIndex: resultIndex, dropZone: dropZone, nextRow: nextRow });
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2868
|
+
clearDropZoneCSS(args.dropZone);
|
|
2869
|
+
$lib.updateStyle(args.element.style, 'left:;top:;');
|
|
2870
|
+
|
|
2871
|
+
if ($lib.isEmpty(args.element.getAttribute('style')))
|
|
2872
|
+
args.element.removeAttribute('style');
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
function updateItemDropZones(dropZones)
|
|
2876
|
+
{
|
|
2877
|
+
$lib.each(_itemDraggables, function (d)
|
|
2878
|
+
{
|
|
2879
|
+
var tr, item;
|
|
2880
|
+
|
|
2881
|
+
if (!dropZones)
|
|
2882
|
+
{
|
|
2883
|
+
tr = getTableRow(d.element),
|
|
2884
|
+
item = loadItem(tr.id.replace(_instance.id + '_', ''));
|
|
2885
|
+
d.settings.dropZones = getItemDropZones(item);
|
|
2886
|
+
}
|
|
2887
|
+
else
|
|
2888
|
+
d.settings.dropZones = dropZones;
|
|
2889
|
+
});
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
function collapseItems(items, expanded)
|
|
2893
|
+
{
|
|
2894
|
+
if (!expanded)
|
|
2895
|
+
expanded = [];
|
|
2896
|
+
|
|
2897
|
+
$lib.each(items, function (i)
|
|
2898
|
+
{
|
|
2899
|
+
if (i.expanded)
|
|
2900
|
+
{
|
|
2901
|
+
expanded.push(i.id);
|
|
2902
|
+
collapseItem(i.id);
|
|
2903
|
+
}
|
|
2904
|
+
});
|
|
2905
|
+
|
|
2906
|
+
return expanded;
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2909
|
+
function getTableRow(el)
|
|
2910
|
+
{
|
|
2911
|
+
return (el.nodeName.toLowerCase() === 'tr') ? el : el.parentNode;
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
function clearDropZoneCSS(dropZone)
|
|
2915
|
+
{
|
|
2916
|
+
$lib.removeClass(dropZone, _classOption.TOP + ' ' + _classOption.BOTTOM);
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2919
|
+
function onSelect(args)
|
|
2920
|
+
{
|
|
2921
|
+
var index;
|
|
2922
|
+
|
|
2923
|
+
for (index = 0; index < args.deselected.length; index++)
|
|
2924
|
+
{
|
|
2925
|
+
deselectItem(args.deselected[index].id.replace(_instance.id + '_', ''), args.event);
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
|
+
for (index = 0; index < args.selected.length; index++)
|
|
2929
|
+
{
|
|
2930
|
+
selectItem(args.selected[index].id.replace(_instance.id + '_', ''), args.event);
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
|
|
2934
|
+
function toggleSelectItem(id)
|
|
2935
|
+
{
|
|
2936
|
+
var isSelected = (_selectedItems[id] != null);
|
|
2937
|
+
|
|
2938
|
+
if (_instance.rowSelection == _rowSelectionOption.MULTI)
|
|
2939
|
+
{
|
|
2940
|
+
// multi: toggle this item only, keep the rest of the selection
|
|
2941
|
+
if (isSelected)
|
|
2942
|
+
deselectItem(id);
|
|
2943
|
+
else
|
|
2944
|
+
selectItem(id);
|
|
2945
|
+
}
|
|
2946
|
+
else
|
|
2947
|
+
{
|
|
2948
|
+
clearSelection(); // single: clear any selection, then select the item unless it was the selected one
|
|
2949
|
+
|
|
2950
|
+
if (!isSelected)
|
|
2951
|
+
selectItem(id);
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
_forceSelect = false;
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2957
|
+
function selectItem(itemId)
|
|
2958
|
+
{
|
|
2959
|
+
if ($lib.isEmpty(itemId))
|
|
2960
|
+
return;
|
|
2961
|
+
|
|
2962
|
+
var item = loadItem(itemId),
|
|
2963
|
+
el = getItemRow(itemId);
|
|
2964
|
+
|
|
2965
|
+
if (!_forceSelect && item.disabled)
|
|
2966
|
+
return;
|
|
2967
|
+
|
|
2968
|
+
_selectedItems[itemId] = item;
|
|
2969
|
+
item.selected = true;
|
|
2970
|
+
storeSelected();
|
|
2971
|
+
$lib.addClass(el, _classOption.SELECTED);
|
|
2972
|
+
|
|
2973
|
+
_forceSelect = false;
|
|
2974
|
+
_instance.events.onItemSelect.fire(_instance, eventArgs(item, el, null));
|
|
2975
|
+
|
|
2976
|
+
selectItemsInGroup(item);
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
function deselectItem(itemId)
|
|
2980
|
+
{
|
|
2981
|
+
if ($lib.isEmpty(itemId))
|
|
2982
|
+
return;
|
|
2983
|
+
|
|
2984
|
+
var item = loadItem(itemId),
|
|
2985
|
+
el = getItemRow(itemId);
|
|
2986
|
+
|
|
2987
|
+
delete _selectedItems[itemId];
|
|
2988
|
+
item.selected = false;
|
|
2989
|
+
storeSelected();
|
|
2990
|
+
$lib.removeClass(el, _classOption.SELECTED);
|
|
2991
|
+
|
|
2992
|
+
_instance.events.onItemDeselect.fire(_instance, eventArgs(item, el, null));
|
|
2993
|
+
|
|
2994
|
+
selectItemsInGroup(item, true);
|
|
2995
|
+
}
|
|
2996
|
+
|
|
2997
|
+
function storeSelected()
|
|
2998
|
+
{
|
|
2999
|
+
var sel = [];
|
|
3000
|
+
$lib.each(_selectedItems, function (item, key)
|
|
3001
|
+
{
|
|
3002
|
+
sel.push((!$lib.isEmpty(item.value)) ? item.value : item.id);
|
|
3003
|
+
});
|
|
3004
|
+
|
|
3005
|
+
_hidden.value = (sel.length > 0) ? sel.join(',') : '';
|
|
3006
|
+
}
|
|
3007
|
+
|
|
3008
|
+
function clearSelection()
|
|
3009
|
+
{
|
|
3010
|
+
if (_selectable)
|
|
3011
|
+
_selectable.deselect();
|
|
3012
|
+
else if (!$lib.isEmpty(_selectedItems))
|
|
3013
|
+
{
|
|
3014
|
+
for (var id in _selectedItems)
|
|
3015
|
+
{
|
|
3016
|
+
deselectItem(id);
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
function selectItemsInGroup(item, deselect)
|
|
3022
|
+
{
|
|
3023
|
+
if (_instance.rowSelection != _rowSelectionOption.MULTI || !item.isGroup)
|
|
3024
|
+
return;
|
|
3025
|
+
|
|
3026
|
+
$lib.each(getItemsInGroup(item.id), function (i)
|
|
3027
|
+
{
|
|
3028
|
+
(deselect) ? deselectItem(i.id) : selectItem(i.id);
|
|
3029
|
+
});
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
function getItemsInGroup(itemId)
|
|
3033
|
+
{
|
|
3034
|
+
var parentIds = [itemId],
|
|
3035
|
+
items = [];
|
|
3036
|
+
|
|
3037
|
+
$lib.each(_instance.itemList, function (i, index)
|
|
3038
|
+
{
|
|
3039
|
+
if ($lib.isEmpty(i.parentId))
|
|
3040
|
+
return;
|
|
3041
|
+
|
|
3042
|
+
if ($lib.indexOf(parentIds, i.parentId) > -1)
|
|
3043
|
+
{
|
|
3044
|
+
if (i.isGroup)
|
|
3045
|
+
parentIds.push(i.id);
|
|
3046
|
+
|
|
3047
|
+
items.push(i);
|
|
3048
|
+
}
|
|
3049
|
+
});
|
|
3050
|
+
|
|
3051
|
+
return items;
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
function removeItem(itemId)
|
|
3055
|
+
{
|
|
3056
|
+
var tr = getItemRow(itemId),
|
|
3057
|
+
index = getIndex(_instance.itemList, itemId),
|
|
3058
|
+
item = _instance.itemList[index],
|
|
3059
|
+
table = _divContent.firstChild;
|
|
3060
|
+
|
|
3061
|
+
if (tr)
|
|
3062
|
+
table.deleteRow(tr.rowIndex); // remove table record
|
|
3063
|
+
|
|
3064
|
+
if (!$lib.isEmpty(item.parentId) && _treeGroup[item.parentId])
|
|
3065
|
+
_treeGroup[item.parentId].items.splice(getIndex(_treeGroup[item.parentId].items, item.id), 1); // remove from item group
|
|
3066
|
+
|
|
3067
|
+
_instance.itemList.splice(index, 1);
|
|
3068
|
+
|
|
3069
|
+
if (item.isGroup)
|
|
3070
|
+
{
|
|
3071
|
+
$lib.each(_treeGroup[item.id], function (i)
|
|
3072
|
+
{
|
|
3073
|
+
removeItem(i.id); // remove child items in group
|
|
3074
|
+
});
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
if (_selectable)
|
|
3078
|
+
_selectable.update();
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
function toggleExpandItem(itemId)
|
|
3082
|
+
{
|
|
3083
|
+
var item = loadItem(itemId);
|
|
3084
|
+
|
|
3085
|
+
if (item.expanded)
|
|
3086
|
+
collapseItem(item.id);
|
|
3087
|
+
else
|
|
3088
|
+
expandItem(item.id);
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
function expandItem(itemId)
|
|
3092
|
+
{
|
|
3093
|
+
var item = loadItem(itemId),
|
|
3094
|
+
tr = getItemRow(itemId),
|
|
3095
|
+
table = _divContent.firstChild, cell,
|
|
3096
|
+
trExpand,
|
|
3097
|
+
templateId = _instance.itemTemplateId || item.templateId,
|
|
3098
|
+
query = { id: itemId };
|
|
3099
|
+
|
|
3100
|
+
if (item.disabled || !templateId)
|
|
3101
|
+
return;
|
|
3102
|
+
|
|
3103
|
+
trExpand = table.insertRow(tr.rowIndex + 1);
|
|
3104
|
+
|
|
3105
|
+
if (_instance.rowExpansion == _rowExpansionOption.SINGLE && !$lib.isEmpty(_expandedItemId))
|
|
3106
|
+
collapseItem(_expandedItemId);
|
|
3107
|
+
|
|
3108
|
+
if (_instance.enableExpandColumn)
|
|
3109
|
+
{
|
|
3110
|
+
cell = trExpand.appendChild(document.createElement('td'));
|
|
3111
|
+
$lib.addClass(cell, _instance.cssClassExpand || _classOption.EXPAND);
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
cell = trExpand.appendChild(document.createElement('td'));
|
|
3115
|
+
cell.colSpan = _instance.columns.length;
|
|
3116
|
+
|
|
3117
|
+
item.expanded = true;
|
|
3118
|
+
$lib.addClass(tr, 'expanded');
|
|
3119
|
+
_expandedItemId = itemId;
|
|
3120
|
+
|
|
3121
|
+
if (_selectable)
|
|
3122
|
+
_selectable.settings.exclude.push(trExpand); // exclude from select list
|
|
3123
|
+
|
|
3124
|
+
if (_instance.ajax.loadItem && _instance.ajax.loadItem.isDefined())
|
|
3125
|
+
{
|
|
3126
|
+
if (_ajax[1])
|
|
3127
|
+
_ajax[1].abort();
|
|
3128
|
+
|
|
3129
|
+
_instance.events.onPreLoadItem.fire(_instance);
|
|
3130
|
+
showItemPreloader(cell);
|
|
3131
|
+
|
|
3132
|
+
_ajax[1] = _instance.ajaxCall('loadItem', window.JSON.stringify(query),
|
|
3133
|
+
{
|
|
3134
|
+
onSuccess: function (args)
|
|
3135
|
+
{
|
|
3136
|
+
var item = (typeof args.data === 'string') ? window.JSON.parse(args.data) : args.data;
|
|
3137
|
+
|
|
3138
|
+
$lib.removeChildren(cell);
|
|
3139
|
+
_instance.applyTemplate(cell, templateId, item);
|
|
3140
|
+
_instance.events.onPostLoadItem.fire(_instance, args);
|
|
3141
|
+
}
|
|
3142
|
+
});
|
|
3143
|
+
}
|
|
3144
|
+
else if (!$lib.isEmpty(templateId))
|
|
3145
|
+
_instance.applyTemplate(cell, templateId, item);
|
|
3146
|
+
|
|
3147
|
+
_instance.events.onItemExpand.fire(_instance, eventArgs(item, tr, cell));
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
function collapseItem(itemId)
|
|
3151
|
+
{
|
|
3152
|
+
var item = loadItem(itemId),
|
|
3153
|
+
tr = getItemRow(itemId),
|
|
3154
|
+
table = _divContent.firstChild,
|
|
3155
|
+
templateId = _instance.itemTemplateId || item.templateId;
|
|
3156
|
+
|
|
3157
|
+
if (item.disabled || !templateId)
|
|
3158
|
+
return;
|
|
3159
|
+
|
|
3160
|
+
item.expanded = false;
|
|
3161
|
+
_expandedItemId = null;
|
|
3162
|
+
$lib.removeClass(tr, 'expanded');
|
|
3163
|
+
|
|
3164
|
+
table.deleteRow(tr.rowIndex + 1);
|
|
3165
|
+
|
|
3166
|
+
_instance.events.onItemCollapse.fire(_instance, eventArgs(item, tr, null));
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3169
|
+
function expandItemGroup(itemId, expand)
|
|
3170
|
+
{
|
|
3171
|
+
var display = (expand) ? '' : null;
|
|
3172
|
+
|
|
3173
|
+
if (expand === false)
|
|
3174
|
+
display = 'none';
|
|
3175
|
+
|
|
3176
|
+
_displayRows(itemId, display);
|
|
3177
|
+
}
|
|
3178
|
+
|
|
3179
|
+
function getGroupColumns(groupId)
|
|
3180
|
+
{
|
|
3181
|
+
var columns = [],
|
|
3182
|
+
findColumns = function (groupId)
|
|
3183
|
+
{
|
|
3184
|
+
$lib.each(_instance.columns, function (column)
|
|
3185
|
+
{
|
|
3186
|
+
if (column.columnGroupId == groupId)
|
|
3187
|
+
columns.push(column);
|
|
3188
|
+
});
|
|
3189
|
+
|
|
3190
|
+
$lib.each(_instance.columnGroups, function (group)
|
|
3191
|
+
{
|
|
3192
|
+
if (group.parentId == groupId)
|
|
3193
|
+
findColumns(group.id);
|
|
3194
|
+
});
|
|
3195
|
+
};
|
|
3196
|
+
|
|
3197
|
+
findColumns(groupId);
|
|
3198
|
+
return columns;
|
|
3199
|
+
}
|
|
3200
|
+
|
|
3201
|
+
function setColumnGroupDisplay(groupId, visible)
|
|
3202
|
+
{
|
|
3203
|
+
var group = _instance.columnGroups[getIndex(_instance.columnGroups, groupId)];
|
|
3204
|
+
group.visible = visible;
|
|
3205
|
+
$lib.each(getGroupColumns(groupId), function (column) { setColumnDisplay(column, visible); });
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3208
|
+
function setColumnDisplay(columnId, visible)
|
|
3209
|
+
{
|
|
3210
|
+
var column = _instance.columns[getIndex(_instance.columns, columnId)],
|
|
3211
|
+
cellIndex = getCellIndex(getIndex(_instance.columns, columnId)),
|
|
3212
|
+
cssClassHiddenColumn = _instance.cssClassHiddenColumn || _classOption.HIDDEN_COLUMN,
|
|
3213
|
+
method = (visible) ? $lib.removeClass : $lib.addClass,
|
|
3214
|
+
headerTable = _divHeader.firstChild, filterTable, contentTable = _divContent.firstChild,
|
|
3215
|
+
rows = $lib.children($lib(null, contentTable, 'tr', true).parentNode);
|
|
3216
|
+
|
|
3217
|
+
column.visible = visible;
|
|
3218
|
+
method($lib.children($lib(null, headerTable, 'th', true).parentNode)[cellIndex], cssClassHiddenColumn);
|
|
3219
|
+
method($lib.children($lib(null, headerTable, 'col', true).parentNode)[cellIndex], cssClassHiddenColumn);
|
|
3220
|
+
method($lib.children($lib(null, contentTable, 'col', true).parentNode)[cellIndex], cssClassHiddenColumn);
|
|
3221
|
+
|
|
3222
|
+
if (_instance.enableFilterRow)
|
|
3223
|
+
{
|
|
3224
|
+
filterTable = _divFilter.firstChild,
|
|
3225
|
+
method($lib.children($lib(null, filterTable, 'th', true).parentNode)[cellIndex], cssClassHiddenColumn);
|
|
3226
|
+
method($lib.children($lib(null, filterTable, 'col', true).parentNode)[cellIndex], cssClassHiddenColumn);
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
for (var index = 0; index < rows.length; ++index)
|
|
3230
|
+
{
|
|
3231
|
+
method($lib.children(rows[index])[cellIndex], cssClassHiddenColumn);
|
|
3232
|
+
} }
|
|
3233
|
+
|
|
3234
|
+
function disableItem(itemId)
|
|
3235
|
+
{
|
|
3236
|
+
var item = loadItem(itemId);
|
|
3237
|
+
|
|
3238
|
+
item.disabled = true;
|
|
3239
|
+
$lib.addClass(getItemRow(itemId), 'disabled');
|
|
3240
|
+
}
|
|
3241
|
+
|
|
3242
|
+
function enableItem(itemId)
|
|
3243
|
+
{
|
|
3244
|
+
var item = loadItem(itemId);
|
|
3245
|
+
|
|
3246
|
+
item.disabled = false;
|
|
3247
|
+
$lib.removeClass(getItemRow(itemId), 'disabled');
|
|
3248
|
+
}
|
|
3249
|
+
|
|
3250
|
+
function getFilterCell(columnId, index)
|
|
3251
|
+
{
|
|
3252
|
+
var filterRow;
|
|
3253
|
+
|
|
3254
|
+
index = (index != undefined) ? index : getIndex(_instance.columns, columnId),
|
|
3255
|
+
filterRow = $lib(_instance.cssClassFilterRow || _classOption.FILTERROW, _instance.element, null, true);
|
|
3256
|
+
|
|
3257
|
+
return $lib.children($lib(null, filterRow, 'tr', true))[getCellIndex(index)];
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
function getColumnTableHeader(columnId)
|
|
3261
|
+
{
|
|
3262
|
+
return $lib($lib.format('#{0}_h_{1}', _instance.id, columnId));
|
|
3263
|
+
}
|
|
3264
|
+
|
|
3265
|
+
|
|
3266
|
+
function storeTableData(args)
|
|
3267
|
+
{
|
|
3268
|
+
var columnId = args.element.id.replace(_instance.id + '_h_', ''),
|
|
3269
|
+
headerTables = $lib(null, _divHeader, 'table'), column, columnWidths = [],
|
|
3270
|
+
sizeDev = $lib.borderAndPadding(_instance.element),
|
|
3271
|
+
expandIndex = (showExpandColumn()) ? 1 : 0;
|
|
3272
|
+
|
|
3273
|
+
// clear
|
|
3274
|
+
_tableData.header = _tableData.filter = _tableData.content = null;
|
|
3275
|
+
// store
|
|
3276
|
+
_tableData.columnIndex = getIndex(_instance.columns, columnId); // no expand offset needed, arrays below already exclude it
|
|
3277
|
+
_tableData.header = getTableCols(headerTables[0]).slice(expandIndex);
|
|
3278
|
+
_tableData.content = getTableCols(_divContent.firstChild).slice(expandIndex);
|
|
3279
|
+
|
|
3280
|
+
if (_instance.enableFilterRow)
|
|
3281
|
+
_tableData.filter = (headerTables[1]) ? getTableCols(headerTables[1]).slice(expandIndex) : null;
|
|
3282
|
+
|
|
3283
|
+
_tableData.totalWidth = _instance.element.offsetWidth - sizeDev.width; // get total width
|
|
3284
|
+
_tableData.columnStartWidth = args.startWidth; // resize column start width
|
|
3285
|
+
|
|
3286
|
+
if (_instance.preserveTotalWidth)
|
|
3287
|
+
{
|
|
3288
|
+
_tableData.columnDistribution = [];
|
|
3289
|
+
column = _instance.columns[_tableData.columnIndex];
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3292
|
+
$lib.each(_instance.columns, function (col, index)
|
|
3293
|
+
{
|
|
3294
|
+
var el = $lib('#' + _instance.id + '_h_' + col.id),
|
|
3295
|
+
offsetWidth = el.offsetWidth;
|
|
3296
|
+
|
|
3297
|
+
columnWidths[index] = offsetWidth;
|
|
3298
|
+
|
|
3299
|
+
if (_instance.preserveTotalWidth && col != column && col.resizable != false && !col.checkBox)
|
|
3300
|
+
_tableData.columnDistribution.push({ index: index, width: offsetWidth });
|
|
3301
|
+
});
|
|
3302
|
+
|
|
3303
|
+
$lib.each(columnWidths, function (width, index)
|
|
3304
|
+
{
|
|
3305
|
+
updateColumnWidth(index, $lib.unit(width)); // make sure that columns have the correct width when table is stretched to fit viewport
|
|
3306
|
+
});
|
|
3307
|
+
|
|
3308
|
+
function getTableCols(table)
|
|
3309
|
+
{
|
|
3310
|
+
var colGroup = $lib(null, table, 'colgroup', true);
|
|
3311
|
+
return $lib(null, colGroup, 'col');
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
function showExpandColumn()
|
|
3316
|
+
{
|
|
3317
|
+
return (_instance.enableExpandColumn && _instance.rowExpansion > _rowExpansionOption.NONE);
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
function getIndex(arr, id)
|
|
3321
|
+
{
|
|
3322
|
+
return $lib.indexOf(arr, function (item) { return (item.id === id.toString()) })
|
|
3323
|
+
}
|
|
3324
|
+
|
|
3325
|
+
function getCellIndex(index)
|
|
3326
|
+
{
|
|
3327
|
+
var expandIndex = (showExpandColumn()) ? 1 : 0;
|
|
3328
|
+
|
|
3329
|
+
return index + expandIndex;
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
function getItemRow(itemId)
|
|
3333
|
+
{
|
|
3334
|
+
return $lib('#' + getItemId(itemId));
|
|
3335
|
+
}
|
|
3336
|
+
|
|
3337
|
+
function getItemId(id)
|
|
3338
|
+
{
|
|
3339
|
+
return _instance.id + '_' + id;
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
function loadItem(itemId)
|
|
3343
|
+
{
|
|
3344
|
+
if (_lastItem && _lastItem.id === itemId)
|
|
3345
|
+
return _lastItem;
|
|
3346
|
+
|
|
3347
|
+
return _lastItem = $lib.path(_instance.itemList, 'itemList', function (item) { return (item.id === itemId) }, true).item;
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3350
|
+
function eventArgs(item, tr, td)
|
|
3351
|
+
{
|
|
3352
|
+
return { item: item, tr: tr, td: td, event: $lib.event }
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
function dispose()
|
|
3356
|
+
{
|
|
3357
|
+
$.each(_timerIds, function (v) { clearTimeout(v); });
|
|
3358
|
+
clearTimeout(_scrollTimerId);
|
|
3359
|
+
clearTimeout(_fixedColumnUpdateTimerId);
|
|
3360
|
+
|
|
3361
|
+
$lib.off(window, 'resize', detectViewportSize);
|
|
3362
|
+
$lib.off(document, 'pointerup', enableDrag);
|
|
3363
|
+
|
|
3364
|
+
if (_elementHandler)
|
|
3365
|
+
$lib.off(_instance.element, 'pointerdown', _elementHandler);
|
|
3366
|
+
|
|
3367
|
+
$lib.each(_documentHandler, function (handlerId)
|
|
3368
|
+
{
|
|
3369
|
+
$lib.off(document, 'pointerup', handlerId);
|
|
3370
|
+
});
|
|
3371
|
+
|
|
3372
|
+
if (_fixedColumnStyleSheet && _fixedColumnStyleSheet.cssRules.length <= 1)
|
|
3373
|
+
$lib.remove(_fixedColumnStyleSheet.ownerNode);
|
|
3374
|
+
|
|
3375
|
+
_timerIds = [];
|
|
3376
|
+
_documentHandler = [];
|
|
3377
|
+
_selectedItems = {};
|
|
3378
|
+
_filter = {};
|
|
3379
|
+
_sort = {};
|
|
3380
|
+
_lastItem = _filterMenu = _fixedColumnStyleSheet = _elementHandler = _selectable = _divNoResult = _divPreloader = _divContent = _divHeader = _divFilter = _expandedItemId = null;
|
|
3381
|
+
}
|
|
3382
|
+
};
|
|
3383
|
+
|
|
3384
|
+
/**
|
|
3385
|
+
* @see {@link componyx.UI.base.methods}
|
|
3386
|
+
*/
|
|
3387
|
+
componyx.UI.Grid.prototype = Object.create($base.methods);
|
|
3388
|
+
componyx.UI.Grid.prototype.constructor = componyx.UI.Grid;
|
|
3389
|
+
|
|
3390
|
+
/**
|
|
3391
|
+
* RowSelectionOption
|
|
3392
|
+
* @readonly
|
|
3393
|
+
* @enum {number}
|
|
3394
|
+
*/
|
|
3395
|
+
componyx.UI.Grid.RowSelectionOption =
|
|
3396
|
+
{
|
|
3397
|
+
NONE: 0,
|
|
3398
|
+
SINGLE: 1,
|
|
3399
|
+
MULTI: 2
|
|
3400
|
+
};
|
|
3401
|
+
|
|
3402
|
+
/**
|
|
3403
|
+
* RowExpansionOption
|
|
3404
|
+
* @readonly
|
|
3405
|
+
* @enum {number}
|
|
3406
|
+
*/
|
|
3407
|
+
componyx.UI.Grid.RowExpansionOption =
|
|
3408
|
+
{
|
|
3409
|
+
NONE: 0,
|
|
3410
|
+
SINGLE: 1,
|
|
3411
|
+
MULTI: 2
|
|
3412
|
+
};
|
|
3413
|
+
|
|
3414
|
+
/**
|
|
3415
|
+
* GroupExpansionOption
|
|
3416
|
+
* @readonly
|
|
3417
|
+
* @enum {number}
|
|
3418
|
+
*/
|
|
3419
|
+
componyx.UI.Grid.GroupExpansionOption =
|
|
3420
|
+
{
|
|
3421
|
+
NONE: 0,
|
|
3422
|
+
ICON: 1,
|
|
3423
|
+
ITEM: 2
|
|
3424
|
+
};
|
|
3425
|
+
|
|
3426
|
+
/**
|
|
3427
|
+
* ColumnSortingOption
|
|
3428
|
+
* @readonly
|
|
3429
|
+
* @enum {number}
|
|
3430
|
+
*/
|
|
3431
|
+
componyx.UI.Grid.ColumnSortingOption =
|
|
3432
|
+
{
|
|
3433
|
+
NONE: 0,
|
|
3434
|
+
SINGLE: 1,
|
|
3435
|
+
MULTI: 2
|
|
3436
|
+
};
|
|
3437
|
+
|
|
3438
|
+
/**
|
|
3439
|
+
* SortOrderOption
|
|
3440
|
+
* @readonly
|
|
3441
|
+
* @enum {number}
|
|
3442
|
+
*/
|
|
3443
|
+
componyx.UI.Grid.SortOrderOption =
|
|
3444
|
+
{
|
|
3445
|
+
ASC: 0,
|
|
3446
|
+
DESC: 1
|
|
3447
|
+
};
|
|
3448
|
+
|
|
3449
|
+
/**
|
|
3450
|
+
* FilterMenuOptions
|
|
3451
|
+
* @readonly
|
|
3452
|
+
* @enum {number}
|
|
3453
|
+
*/
|
|
3454
|
+
componyx.UI.Grid.FilterMenuOptions =
|
|
3455
|
+
{
|
|
3456
|
+
EQUALTO: 1,
|
|
3457
|
+
NOTEQUALTO: 2,
|
|
3458
|
+
GREATERTHAN: 4,
|
|
3459
|
+
GREATERTHANOREQUALTO: 8,
|
|
3460
|
+
LESSTHAN: 16,
|
|
3461
|
+
LESSTHANOREQUALTO: 32,
|
|
3462
|
+
STARTSWITH: 64,
|
|
3463
|
+
NOTSTARTSWITH: 128,
|
|
3464
|
+
ENDSWITH: 256,
|
|
3465
|
+
NOTENDSWITH: 512,
|
|
3466
|
+
CONTAINS: 1024,
|
|
3467
|
+
NOTCONTAINS: 2048,
|
|
3468
|
+
BETWEEN: 4096,
|
|
3469
|
+
NOTBETWEEN: 8192,
|
|
3470
|
+
IN: 16384,
|
|
3471
|
+
NOTIN: 32768,
|
|
3472
|
+
EMPTY: 65536,
|
|
3473
|
+
NOTEMPTY: 131072,
|
|
3474
|
+
|
|
3475
|
+
getName: function (value) { return $base.static.getKeyByValue(this, value).toLowerCase(); }
|
|
3476
|
+
};
|
|
3477
|
+
|
|
3478
|
+
/**
|
|
3479
|
+
* FilterInputTypeOption
|
|
3480
|
+
* @readonly
|
|
3481
|
+
* @enum {number}
|
|
3482
|
+
*/
|
|
3483
|
+
componyx.UI.Grid.FilterInputTypeOption =
|
|
3484
|
+
{
|
|
3485
|
+
TEXTBOX: 0,
|
|
3486
|
+
NUMERICBOX: 1,
|
|
3487
|
+
COMBOBOX: 2,
|
|
3488
|
+
DATEPICKER: 3,
|
|
3489
|
+
TIMEPICKER: 4,
|
|
3490
|
+
SLIDER: 5
|
|
3491
|
+
};
|
|
3492
|
+
|
|
3493
|
+
/**
|
|
3494
|
+
* Creates an instance of the Grid Item.
|
|
3495
|
+
* @class
|
|
3496
|
+
* @memberof componyx.UI.Grid
|
|
3497
|
+
* @param {Object} properties The properties used to initialize the object.
|
|
3498
|
+
* @property {String} properties.cssClassCheckBox Gets or sets the css class of a check box cell.
|
|
3499
|
+
* @property {String} properties.cssClassExpand Gets or sets the css class of an expand cell.
|
|
3500
|
+
* @property {Boolean} properties.draggable Gets or sets a value indicating if the row is draggable.
|
|
3501
|
+
* @property {Boolean} properties.expandable Gets or sets a value indicating if the row is expandable and collapsible.
|
|
3502
|
+
* @property {Boolean} properties.expanded Gets or sets a value indicating if the row is (initially) expanded.
|
|
3503
|
+
* @property {Boolean} properties.isGroup Gets or sets a value indicating if the item holds a group of child-items.
|
|
3504
|
+
* @property {Boolean} properties.groupExpandable Gets or sets a value indicating if the group is expandable and collapsible.
|
|
3505
|
+
* @property {Boolean} properties.groupExpanded Gets or sets a value indicating if the group is (initially) expanded.
|
|
3506
|
+
* @property {Number} properties.groupIndent Gets or sets the indent value of the group in pixels.
|
|
3507
|
+
* @property {String} properties.parentId Gets or sets the id of the parent group-item to which this item belongs (IsGroup on parent item must be enabled).
|
|
3508
|
+
* @augments componyx.UI.base.static.Item
|
|
3509
|
+
* @see {@link componyx.UI.base.static.Item}
|
|
3510
|
+
*/
|
|
3511
|
+
componyx.UI.Grid.Item = class GridItem
|
|
3512
|
+
{
|
|
3513
|
+
constructor(properties)
|
|
3514
|
+
{
|
|
3515
|
+
|
|
3516
|
+
/** Gets or sets the css class of a check box cell.
|
|
3517
|
+
* @type {String}
|
|
3518
|
+
*/
|
|
3519
|
+
this.cssClassCheckBox = '';
|
|
3520
|
+
|
|
3521
|
+
/** Gets or sets the css class of an expand cell.
|
|
3522
|
+
* @type {String}
|
|
3523
|
+
*/
|
|
3524
|
+
this.cssClassExpand = '';
|
|
3525
|
+
|
|
3526
|
+
/** Gets or sets a value indicating if the row is draggable.
|
|
3527
|
+
* @type {Boolean}
|
|
3528
|
+
*/
|
|
3529
|
+
this.draggable = true;
|
|
3530
|
+
|
|
3531
|
+
/** Gets or sets a value indicating if the row is expandable and collapsible.
|
|
3532
|
+
* @type {Boolean}
|
|
3533
|
+
*/
|
|
3534
|
+
this.expandable = true;
|
|
3535
|
+
|
|
3536
|
+
/** Gets or sets a value indicating if the row is (initially) expanded.
|
|
3537
|
+
* @type {Boolean}
|
|
3538
|
+
*/
|
|
3539
|
+
this.expanded = false;
|
|
3540
|
+
|
|
3541
|
+
/** Gets or sets a value indicating if the item holds a group of child-items.
|
|
3542
|
+
* @type {Boolean}
|
|
3543
|
+
*/
|
|
3544
|
+
this.isGroup = false;
|
|
3545
|
+
|
|
3546
|
+
/** Gets or sets a value indicating if the group is expandable and collapsible.
|
|
3547
|
+
* @type {Boolean}
|
|
3548
|
+
*/
|
|
3549
|
+
this.groupExpandable = true;
|
|
3550
|
+
|
|
3551
|
+
/** Gets or sets a value indicating if the group is (initially) expanded.
|
|
3552
|
+
* @type {Boolean}
|
|
3553
|
+
*/
|
|
3554
|
+
this.groupExpanded = true;
|
|
3555
|
+
|
|
3556
|
+
/** Gets or sets the indent value of the group in pixels.
|
|
3557
|
+
* @type {Number|null}
|
|
3558
|
+
*/
|
|
3559
|
+
this.groupIndent = null;
|
|
3560
|
+
|
|
3561
|
+
/** Gets or sets the id of the parent group-item to which this item belongs (IsGroup on parent item must be enabled).
|
|
3562
|
+
* @type {String|null}
|
|
3563
|
+
*/
|
|
3564
|
+
this.parentId = null;
|
|
3565
|
+
|
|
3566
|
+
// call original base constructor logic as you requested
|
|
3567
|
+
$base.static.Item.call(this, properties);
|
|
3568
|
+
}
|
|
3569
|
+
};
|
|
3570
|
+
|
|
3571
|
+
/**
|
|
3572
|
+
* Creates an instance of the Grid ColumnGroup.
|
|
3573
|
+
* @class
|
|
3574
|
+
* @memberof componyx.UI.Grid
|
|
3575
|
+
* @param {Object} properties The properties used to initialize the object.
|
|
3576
|
+
* @property {String} properties.id Gets or sets the id of the column group.
|
|
3577
|
+
* @property {String} properties.parentId Gets or sets the parent group id for nesting column groups.
|
|
3578
|
+
* @property {String} properties.headerText Gets or sets the header text of the column group.
|
|
3579
|
+
* @property {String} properties.cssClass Gets or sets the css class of the column group.
|
|
3580
|
+
* @property {String} properties.style Gets or sets the css style of the column group.
|
|
3581
|
+
*/
|
|
3582
|
+
componyx.UI.Grid.ColumnGroup = class ColumnGroup
|
|
3583
|
+
{
|
|
3584
|
+
constructor(properties)
|
|
3585
|
+
{
|
|
3586
|
+
|
|
3587
|
+
/** Gets or sets the id of the column group.
|
|
3588
|
+
* @type {String|null}
|
|
3589
|
+
*/
|
|
3590
|
+
this.id = null;
|
|
3591
|
+
|
|
3592
|
+
/** Gets or sets the parent group id for nesting column groups.
|
|
3593
|
+
* @type {String|null}
|
|
3594
|
+
*/
|
|
3595
|
+
this.parentId = null;
|
|
3596
|
+
|
|
3597
|
+
/** Gets or sets the header text of the column group.
|
|
3598
|
+
* @type {String|null}
|
|
3599
|
+
*/
|
|
3600
|
+
this.headerText = null;
|
|
3601
|
+
|
|
3602
|
+
/** Gets or sets the css class of the column group.
|
|
3603
|
+
* @type {String|null}
|
|
3604
|
+
*/
|
|
3605
|
+
this.cssClass = null;
|
|
3606
|
+
|
|
3607
|
+
/** Gets or sets the css style of the column group.
|
|
3608
|
+
* @type {String|null}
|
|
3609
|
+
*/
|
|
3610
|
+
this.style = null;
|
|
3611
|
+
|
|
3612
|
+
$lib.clone(this, properties, true, true, true, true, false);
|
|
3613
|
+
}
|
|
3614
|
+
};
|
|
3615
|
+
|
|
3616
|
+
/**
|
|
3617
|
+
* Creates an instance of the Grid Column.
|
|
3618
|
+
* @class
|
|
3619
|
+
* @memberof componyx.UI.Grid
|
|
3620
|
+
* @param {Object} properties The properties used to initialize the object.
|
|
3621
|
+
* @property {String} properties.id Gets or sets the id of the column.
|
|
3622
|
+
* @property {String} properties.columnGroupId Gets or sets the column group id.
|
|
3623
|
+
* @property {String} properties.headerText Gets or sets the header text of the column.
|
|
3624
|
+
* @property {String} properties.cssClassHeader Gets or sets the css class of the header column.
|
|
3625
|
+
* @property {String} properties.cssClass Gets or sets the css class of the column.
|
|
3626
|
+
* @property {String} properties.style Gets or sets the css style of the column header.
|
|
3627
|
+
* @property {String} properties.width Gets or sets the width of the column.
|
|
3628
|
+
* @property {Boolean} properties.resizable Gets or sets a value indicating if the column can be resized (defaults to true).
|
|
3629
|
+
* @property {Boolean} properties.checkBox Gets or sets a value indicating if the column is a checkbox column.
|
|
3630
|
+
* @property {Boolean} properties.visible Gets or sets a value indicating if the column is visible.
|
|
3631
|
+
* @property {Boolean} properties.disableSorting Gets or sets a value indicating if the sorting is disabled for this column.
|
|
3632
|
+
* @property {Boolean} properties.disableFilter Gets or sets a value indicating if the filter is disabled for this column when enableFilterRow is set to true.
|
|
3633
|
+
* @property {FilterMenuOptions} properties.filterMenuOptions Gets or sets one or more FilterMenuOptions options.
|
|
3634
|
+
* @property {FilterMenuSelectedOption} properties.filterMenuSelectedOption Gets or sets which filter-menu option is initially selected.
|
|
3635
|
+
* @property {FilterInputTypeOption} properties.filterInputType Gets or sets one of the FilterInputTypeOption.
|
|
3636
|
+
* @property {HTMLElement|HTMLElement[]|DocumentFragment|String} properties.headerTooltipTemplate Gets or sets the header tooltip template.
|
|
3637
|
+
* @property {HTMLElement|HTMLElement[]|DocumentFragment|String} properties.columnTemplate Gets or sets the column template. All item properties can be used in the template as interpolations via '{propertyName}'.
|
|
3638
|
+
* @property {HTMLElement|HTMLElement[]|DocumentFragment|String} properties.filterTemplate Gets or sets the filter template.
|
|
3639
|
+
* @property {HTMLElement|HTMLElement[]|DocumentFragment|String} properties.rangeFilterTemplate Gets or sets the range filter template.
|
|
3640
|
+
* @property {String} properties.filterButtonId Gets or sets the id of the filter Button component from which the settings are cloned.
|
|
3641
|
+
* @property {String} properties.filterInputId Gets or sets the id of the UI component (NumericBox, ComboBox, DatePicker, TimePicker, Slider) from which the settings are cloned.
|
|
3642
|
+
*/
|
|
3643
|
+
componyx.UI.Grid.Column = class Column
|
|
3644
|
+
{
|
|
3645
|
+
constructor(properties)
|
|
3646
|
+
{
|
|
3647
|
+
|
|
3648
|
+
/** Gets or sets the id of the column.
|
|
3649
|
+
* @type {String|null}
|
|
3650
|
+
*/
|
|
3651
|
+
this.id = null;
|
|
3652
|
+
|
|
3653
|
+
/** Gets or sets the column group id.
|
|
3654
|
+
* @type {String|null}
|
|
3655
|
+
*/
|
|
3656
|
+
this.columnGroupId = null;
|
|
3657
|
+
|
|
3658
|
+
/** Gets or sets the header text of the column.
|
|
3659
|
+
* @type {String|null}
|
|
3660
|
+
*/
|
|
3661
|
+
this.headerText = null;
|
|
3662
|
+
|
|
3663
|
+
/** Gets or sets the css class of the header column.
|
|
3664
|
+
* @type {String|null}
|
|
3665
|
+
*/
|
|
3666
|
+
this.cssClassHeader = null;
|
|
3667
|
+
|
|
3668
|
+
/** Gets or sets the css class of the column.
|
|
3669
|
+
* @type {String|null}
|
|
3670
|
+
*/
|
|
3671
|
+
this.cssClass = null;
|
|
3672
|
+
|
|
3673
|
+
/** Gets or sets the css style of the column header.
|
|
3674
|
+
* @type {String|null}
|
|
3675
|
+
*/
|
|
3676
|
+
this.style = null;
|
|
3677
|
+
|
|
3678
|
+
/** Gets or sets the width of the column.
|
|
3679
|
+
* @type {String|null}
|
|
3680
|
+
*/
|
|
3681
|
+
this.width = null;
|
|
3682
|
+
|
|
3683
|
+
/** Gets or sets a value indicating if the column can be resized (defaults to true).
|
|
3684
|
+
* @type {Boolean}
|
|
3685
|
+
*/
|
|
3686
|
+
this.resizable = true;
|
|
3687
|
+
|
|
3688
|
+
/** Gets or sets a value indicating if the column is a checkbox column.
|
|
3689
|
+
* @type {Boolean}
|
|
3690
|
+
*/
|
|
3691
|
+
this.checkBox = false;
|
|
3692
|
+
|
|
3693
|
+
/** Gets or sets a value indicating if the column is visible.
|
|
3694
|
+
* @type {Boolean}
|
|
3695
|
+
*/
|
|
3696
|
+
this.visible = true;
|
|
3697
|
+
|
|
3698
|
+
/** Gets or sets a value indicating if the sorting is disabled for this column.
|
|
3699
|
+
* @type {Boolean}
|
|
3700
|
+
*/
|
|
3701
|
+
this.disableSorting = false;
|
|
3702
|
+
|
|
3703
|
+
/** Gets or sets a value indicating if the filter is disabled for this column when enableFilterRow is set to true.
|
|
3704
|
+
* @type {Boolean}
|
|
3705
|
+
*/
|
|
3706
|
+
this.disableFilter = false;
|
|
3707
|
+
|
|
3708
|
+
/** Gets or sets one or more FilterMenuOptions options.
|
|
3709
|
+
* @type {FilterMenuOptions|null}
|
|
3710
|
+
*/
|
|
3711
|
+
this.filterMenuOptions = null;
|
|
3712
|
+
|
|
3713
|
+
/** Gets or sets which filter-menu option is initially selected.
|
|
3714
|
+
* @type {FilterMenuSelectedOption|null}
|
|
3715
|
+
*/
|
|
3716
|
+
this.filterMenuSelectedOption = null;
|
|
3717
|
+
|
|
3718
|
+
/** Gets or sets one of the FilterInputTypeOption.
|
|
3719
|
+
* @type {FilterInputTypeOption|null}
|
|
3720
|
+
*/
|
|
3721
|
+
this.filterInputType = null;
|
|
3722
|
+
|
|
3723
|
+
/** Gets or sets the header tooltip template.
|
|
3724
|
+
* @type {HTMLElement|HTMLElement[]|DocumentFragment|String|null}
|
|
3725
|
+
*/
|
|
3726
|
+
this.headerTooltipTemplate = null;
|
|
3727
|
+
|
|
3728
|
+
/** Gets or sets the column template. All item properties can be used in the template as interpolations via '{propertyName}'.
|
|
3729
|
+
* @type {HTMLElement|HTMLElement[]|DocumentFragment|String|null}
|
|
3730
|
+
*/
|
|
3731
|
+
this.columnTemplate = null;
|
|
3732
|
+
|
|
3733
|
+
/** Gets or sets the filter template.
|
|
3734
|
+
* @type {HTMLElement|HTMLElement[]|DocumentFragment|String|null}
|
|
3735
|
+
*/
|
|
3736
|
+
this.filterTemplate = null;
|
|
3737
|
+
|
|
3738
|
+
/** Gets or sets the range filter template.
|
|
3739
|
+
* @type {HTMLElement|HTMLElement[]|DocumentFragment|String|null}
|
|
3740
|
+
*/
|
|
3741
|
+
this.rangeFilterTemplate = null;
|
|
3742
|
+
|
|
3743
|
+
/** Gets or sets the id of the filter Button component from which the settings are cloned.
|
|
3744
|
+
* @type {String|null}
|
|
3745
|
+
*/
|
|
3746
|
+
this.filterButtonId = null;
|
|
3747
|
+
|
|
3748
|
+
/** Gets or sets the id of the UI component (NumericBox, ComboBox, DatePicker, TimePicker, Slider) from which the settings are cloned.
|
|
3749
|
+
* @type {String|null}
|
|
3750
|
+
*/
|
|
3751
|
+
this.filterInputId = null;
|
|
3752
|
+
|
|
3753
|
+
$lib.clone(this, properties, true, true, true, true, false);
|
|
3754
|
+
}
|
|
3755
|
+
};
|
|
3756
|
+
|
|
3757
|
+
})(window);
|
|
3758
|
+
|
|
3759
|
+
const Grid = componyx.UI.Grid;
|
|
3760
|
+
|
|
3761
|
+
export { Grid };
|