slickgrid 2.3.16
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.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +30 -0
- data/lib/slickgrid.rb +6 -0
- data/lib/slickgrid/version.rb +3 -0
- data/slickgrid.gemspec +20 -0
- data/vendor/assets/images/slickgrid/CheckboxN.png +0 -0
- data/vendor/assets/images/slickgrid/CheckboxY.png +0 -0
- data/vendor/assets/images/slickgrid/GrpCheckboxN.png +0 -0
- data/vendor/assets/images/slickgrid/GrpCheckboxY.png +0 -0
- data/vendor/assets/images/slickgrid/actions.gif +0 -0
- data/vendor/assets/images/slickgrid/ajax-loader-small.gif +0 -0
- data/vendor/assets/images/slickgrid/arrow-right.gif +0 -0
- data/vendor/assets/images/slickgrid/arrow_redo.png +0 -0
- data/vendor/assets/images/slickgrid/arrow_right_peppermint.png +0 -0
- data/vendor/assets/images/slickgrid/arrow_right_spearmint.png +0 -0
- data/vendor/assets/images/slickgrid/arrow_undo.png +0 -0
- data/vendor/assets/images/slickgrid/bullet_blue.png +0 -0
- data/vendor/assets/images/slickgrid/bullet_star.png +0 -0
- data/vendor/assets/images/slickgrid/bullet_toggle_minus.png +0 -0
- data/vendor/assets/images/slickgrid/bullet_toggle_plus.png +0 -0
- data/vendor/assets/images/slickgrid/calendar.gif +0 -0
- data/vendor/assets/images/slickgrid/collapse.gif +0 -0
- data/vendor/assets/images/slickgrid/comment_yellow.gif +0 -0
- data/vendor/assets/images/slickgrid/delete.png +0 -0
- data/vendor/assets/images/slickgrid/down.gif +0 -0
- data/vendor/assets/images/slickgrid/drag-handle.png +0 -0
- data/vendor/assets/images/slickgrid/editor-helper-bg.gif +0 -0
- data/vendor/assets/images/slickgrid/expand.gif +0 -0
- data/vendor/assets/images/slickgrid/header-bg.gif +0 -0
- data/vendor/assets/images/slickgrid/header-columns-bg.gif +0 -0
- data/vendor/assets/images/slickgrid/header-columns-over-bg.gif +0 -0
- data/vendor/assets/images/slickgrid/help.png +0 -0
- data/vendor/assets/images/slickgrid/info.gif +0 -0
- data/vendor/assets/images/slickgrid/listview.gif +0 -0
- data/vendor/assets/images/slickgrid/pencil.gif +0 -0
- data/vendor/assets/images/slickgrid/row-over-bg.gif +0 -0
- data/vendor/assets/images/slickgrid/sort-asc.gif +0 -0
- data/vendor/assets/images/slickgrid/sort-asc.png +0 -0
- data/vendor/assets/images/slickgrid/sort-desc.gif +0 -0
- data/vendor/assets/images/slickgrid/sort-desc.png +0 -0
- data/vendor/assets/images/slickgrid/stripes.png +0 -0
- data/vendor/assets/images/slickgrid/tag_red.png +0 -0
- data/vendor/assets/images/slickgrid/tick.png +0 -0
- data/vendor/assets/images/slickgrid/user_identity.gif +0 -0
- data/vendor/assets/images/slickgrid/user_identity_plus.gif +0 -0
- data/vendor/assets/javascripts/slickgrid.js +5 -0
- data/vendor/assets/javascripts/slickgrid/controls/columnpicker.js +221 -0
- data/vendor/assets/javascripts/slickgrid/controls/gridmenu.js +429 -0
- data/vendor/assets/javascripts/slickgrid/controls/pager.js +154 -0
- data/vendor/assets/javascripts/slickgrid/core.js +493 -0
- data/vendor/assets/javascripts/slickgrid/dataview.js +1220 -0
- data/vendor/assets/javascripts/slickgrid/editors.js +640 -0
- data/vendor/assets/javascripts/slickgrid/formatters.js +65 -0
- data/vendor/assets/javascripts/slickgrid/grid.js +3990 -0
- data/vendor/assets/javascripts/slickgrid/groupitemmetadataprovider.js +172 -0
- data/vendor/assets/javascripts/slickgrid/plugins/autotooltips.js +83 -0
- data/vendor/assets/javascripts/slickgrid/plugins/cellcopymanager.js +88 -0
- data/vendor/assets/javascripts/slickgrid/plugins/cellexternalcopymanager.js +452 -0
- data/vendor/assets/javascripts/slickgrid/plugins/cellrangedecorator.js +72 -0
- data/vendor/assets/javascripts/slickgrid/plugins/cellrangeselector.js +123 -0
- data/vendor/assets/javascripts/slickgrid/plugins/cellselectionmodel.js +168 -0
- data/vendor/assets/javascripts/slickgrid/plugins/checkboxselectcolumn.js +202 -0
- data/vendor/assets/javascripts/slickgrid/plugins/draggablegrouping.js +207 -0
- data/vendor/assets/javascripts/slickgrid/plugins/headerbuttons.js +177 -0
- data/vendor/assets/javascripts/slickgrid/plugins/headermenu.js +296 -0
- data/vendor/assets/javascripts/slickgrid/plugins/rowdetailview.js +455 -0
- data/vendor/assets/javascripts/slickgrid/plugins/rowmovemanager.js +138 -0
- data/vendor/assets/javascripts/slickgrid/plugins/rowselectionmodel.js +191 -0
- data/vendor/assets/javascripts/slickgrid/remotemodel.js +169 -0
- data/vendor/assets/stylesheets/slickgrid.scss +1 -0
- data/vendor/assets/stylesheets/slickgrid/controls/columnpicker.css +46 -0
- data/vendor/assets/stylesheets/slickgrid/controls/gridmenu.css +113 -0
- data/vendor/assets/stylesheets/slickgrid/controls/pager.css +41 -0
- data/vendor/assets/stylesheets/slickgrid/default-theme.css +132 -0
- data/vendor/assets/stylesheets/slickgrid/grid.css +189 -0
- data/vendor/assets/stylesheets/slickgrid/plugins/headerbuttons.css +39 -0
- data/vendor/assets/stylesheets/slickgrid/plugins/headermenu.css +59 -0
- data/vendor/assets/stylesheets/slickgrid/plugins/rowdetailview.css +39 -0
- metadata +165 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* A plugin to add row detail panel
|
|
3
|
+
* Original StackOverflow question & article making this possible (thanks to violet313)
|
|
4
|
+
* https://stackoverflow.com/questions/10535164/can-slickgrids-row-height-be-dynamically-altered#29399927
|
|
5
|
+
* http://violet313.org/slickgrids/#intro
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* USAGE:
|
|
9
|
+
*
|
|
10
|
+
* Add the slick.rowDetailView.(js|css) files and register the plugin with the grid.
|
|
11
|
+
*
|
|
12
|
+
* AVAILABLE ROW DETAIL OPTIONS:
|
|
13
|
+
* cssClass: A CSS class to be added to the row detail
|
|
14
|
+
* loadOnce: Booleang flag, when True will load the data once and then reuse it.
|
|
15
|
+
* preTemplate: Template that will be used before the async process (typically used to show a spinner/loading)
|
|
16
|
+
* postTemplate: Template that will be loaded once the async function finishes
|
|
17
|
+
* process: Async server function call
|
|
18
|
+
* panelRows: Row count to use for the template panel
|
|
19
|
+
* useRowClick: Boolean flag, when True will open the row detail on a row click (from any column), default to False
|
|
20
|
+
*
|
|
21
|
+
* AVAILABLE PUBLIC OPTIONS:
|
|
22
|
+
* init: initiliaze the plugin
|
|
23
|
+
* destroy: destroy the plugin and it's events
|
|
24
|
+
* collapseAll: collapse all opened row detail panel
|
|
25
|
+
* getColumnDefinition: get the column definitions
|
|
26
|
+
* getOptions: get current plugin options
|
|
27
|
+
* setOptions: set or change some of the plugin options
|
|
28
|
+
*
|
|
29
|
+
* THE PLUGIN EXPOSES THE FOLLOWING SLICK EVENTS:
|
|
30
|
+
* onAsyncResponse: This event must be used with the "notify" by the end user once the Asynchronous Server call returns the item detail
|
|
31
|
+
* Event args:
|
|
32
|
+
* itemDetail: Item detail returned from the async server call
|
|
33
|
+
* detailView: An explicit view to use instead of template (Optional)
|
|
34
|
+
*
|
|
35
|
+
* onAsyncEndUpdate: Fired when the async response finished
|
|
36
|
+
* Event args:
|
|
37
|
+
* grid: Reference to the grid.
|
|
38
|
+
* itemDetail: Column definition.
|
|
39
|
+
*
|
|
40
|
+
* onBeforeRowDetailToggle: Fired before the row detail gets toggled
|
|
41
|
+
* Event args:
|
|
42
|
+
* grid: Reference to the grid.
|
|
43
|
+
* item: Column definition.
|
|
44
|
+
*
|
|
45
|
+
* onAfterRowDetailToggle: Fired after the row detail gets toggled
|
|
46
|
+
* Event args:
|
|
47
|
+
* grid: Reference to the grid.
|
|
48
|
+
* item: Column definition.
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
(function ($) {
|
|
52
|
+
// register namespace
|
|
53
|
+
$.extend(true, window, {
|
|
54
|
+
"Slick": {
|
|
55
|
+
"Plugins": {
|
|
56
|
+
"RowDetailView": RowDetailView
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
function RowDetailView(options) {
|
|
63
|
+
var _grid;
|
|
64
|
+
var _self = this;
|
|
65
|
+
var _expandedRows = [];
|
|
66
|
+
var _handler = new Slick.EventHandler();
|
|
67
|
+
var _defaults = {
|
|
68
|
+
columnId: "_detail_selector",
|
|
69
|
+
cssClass: null,
|
|
70
|
+
toolTip: "",
|
|
71
|
+
width: 30
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var _options = $.extend(true, {}, _defaults, options);
|
|
75
|
+
|
|
76
|
+
function init(grid) {
|
|
77
|
+
_grid = grid;
|
|
78
|
+
_dataView = _grid.getData();
|
|
79
|
+
|
|
80
|
+
// Update the minRowBuffer so that the view doesn't disappear when it's at top of screen + the original default 3
|
|
81
|
+
_grid.getOptions().minRowBuffer = _options.panelRows + 3;
|
|
82
|
+
|
|
83
|
+
_handler
|
|
84
|
+
.subscribe(_grid.onClick, handleClick)
|
|
85
|
+
.subscribe(_grid.onSort, handleSort)
|
|
86
|
+
.subscribe(_grid.onScroll, handleScroll);
|
|
87
|
+
|
|
88
|
+
_grid.getData().onRowCountChanged.subscribe(function () { _grid.updateRowCount(); _grid.render(); });
|
|
89
|
+
_grid.getData().onRowsChanged.subscribe(function (e, a) { _grid.invalidateRows(a.rows); _grid.render(); });
|
|
90
|
+
|
|
91
|
+
// subscribe to the onAsyncResponse so that the plugin knows when the user server side calls finished
|
|
92
|
+
subscribeToOnAsyncResponse();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function destroy() {
|
|
96
|
+
_handler.unsubscribeAll();
|
|
97
|
+
_self.onAsyncResponse.unsubscribe();
|
|
98
|
+
_self.onAsyncEndUpdate.unsubscribe();
|
|
99
|
+
_self.onAfterRowDetailToggle.unsubscribe();
|
|
100
|
+
_self.onBeforeRowDetailToggle.unsubscribe();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getOptions(options) {
|
|
104
|
+
return _options;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function setOptions(options) {
|
|
108
|
+
_options = $.extend(true, {}, _options, options);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function handleClick(e, args) {
|
|
112
|
+
// clicking on a row select checkbox
|
|
113
|
+
if (_options.useRowClick || _grid.getColumns()[args.cell].id === _options.columnId && $(e.target).hasClass("detailView-toggle")) {
|
|
114
|
+
// if editing, try to commit
|
|
115
|
+
if (_grid.getEditorLock().isActive() && !_grid.getEditorLock().commitCurrentEdit()) {
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
e.stopImmediatePropagation();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var item = _dataView.getItem(args.row);
|
|
122
|
+
|
|
123
|
+
// trigger an event before toggling
|
|
124
|
+
_self.onBeforeRowDetailToggle.notify({
|
|
125
|
+
"grid": _grid,
|
|
126
|
+
"item": item
|
|
127
|
+
}, e, _self);
|
|
128
|
+
|
|
129
|
+
toggleRowSelection(item);
|
|
130
|
+
|
|
131
|
+
// trigger an event after toggling
|
|
132
|
+
_self.onAfterRowDetailToggle.notify({
|
|
133
|
+
"grid": _grid,
|
|
134
|
+
"item": item
|
|
135
|
+
}, e, _self);
|
|
136
|
+
|
|
137
|
+
e.stopPropagation();
|
|
138
|
+
e.stopImmediatePropagation();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Sort will just collapse all of the open items
|
|
143
|
+
function handleSort(e, args) {
|
|
144
|
+
collapseAll();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// If we scroll save detail views that go out of cache range
|
|
148
|
+
function handleScroll(e, args) {
|
|
149
|
+
|
|
150
|
+
var range = _grid.getRenderedRange();
|
|
151
|
+
|
|
152
|
+
var start = (range.top > 0 ? range.top : 0);
|
|
153
|
+
var end = (range.bottom > _dataView.getLength() ? range.bottom : _dataView.getLength());
|
|
154
|
+
|
|
155
|
+
// Get the item at the top of the view
|
|
156
|
+
var topMostItem = _dataView.getItemByIdx(start);
|
|
157
|
+
|
|
158
|
+
// Check it is a parent item
|
|
159
|
+
if (topMostItem._parent == undefined)
|
|
160
|
+
{
|
|
161
|
+
// This is a standard row as we have no parent.
|
|
162
|
+
var nextItem = _dataView.getItemByIdx(start + 1);
|
|
163
|
+
if(nextItem !== undefined && nextItem._parent !== undefined)
|
|
164
|
+
{
|
|
165
|
+
// This is likely the expanded Detail Row View
|
|
166
|
+
// Check for safety
|
|
167
|
+
if(nextItem._parent == topMostItem)
|
|
168
|
+
{
|
|
169
|
+
saveDetailView(topMostItem);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Find the bottom most item that is likely to go off screen
|
|
175
|
+
var bottomMostItem = _dataView.getItemByIdx(end - 1);
|
|
176
|
+
|
|
177
|
+
// If we are a detailView and we are about to go out of cache view
|
|
178
|
+
if(bottomMostItem._parent !== undefined)
|
|
179
|
+
{
|
|
180
|
+
saveDetailView(bottomMostItem._parent);
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Toggle between showing and hiding a row
|
|
186
|
+
function toggleRowSelection(row) {
|
|
187
|
+
_grid.getData().beginUpdate();
|
|
188
|
+
HandleAccordionShowHide(row);
|
|
189
|
+
_grid.getData().endUpdate();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Collapse all of the open items
|
|
193
|
+
function collapseAll() {
|
|
194
|
+
for (var i = _expandedRows.length - 1; i >= 0; i--) {
|
|
195
|
+
collapseItem(_expandedRows[i]);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Saves the current state of the detail view
|
|
200
|
+
function saveDetailView(item)
|
|
201
|
+
{
|
|
202
|
+
var view = $("#innerDetailView_" + item.id);
|
|
203
|
+
if (view)
|
|
204
|
+
{
|
|
205
|
+
var html = $("#innerDetailView_" + item.id).html();
|
|
206
|
+
if(html !== undefined)
|
|
207
|
+
{
|
|
208
|
+
item._detailContent = html;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Colapse an Item so it is notlonger seen
|
|
214
|
+
function collapseItem(item) {
|
|
215
|
+
|
|
216
|
+
// Save the details on the collapse assuming onetime loading
|
|
217
|
+
if (_options.loadOnce) {
|
|
218
|
+
saveDetailView(item);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
item._collapsed = true;
|
|
222
|
+
for (var idx = 1; idx <= item._sizePadding; idx++) {
|
|
223
|
+
_dataView.deleteItem(item.id + "." + idx);
|
|
224
|
+
}
|
|
225
|
+
item._sizePadding = 0;
|
|
226
|
+
_dataView.updateItem(item.id, item);
|
|
227
|
+
|
|
228
|
+
// Remove the item from the expandedRows
|
|
229
|
+
_expandedRows = _expandedRows.filter(function (r) {
|
|
230
|
+
return r.id !== item.id;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Expand a row given the dataview item that is to be expanded
|
|
235
|
+
function expandItem(item) {
|
|
236
|
+
item._collapsed = false;
|
|
237
|
+
_expandedRows.push(item);
|
|
238
|
+
|
|
239
|
+
// In the case something went wrong loading it the first time such a scroll of screen before loaded
|
|
240
|
+
if (!item._detailContent) item._detailViewLoaded = false;
|
|
241
|
+
|
|
242
|
+
// display pre-loading template
|
|
243
|
+
if (!item._detailViewLoaded || _options.loadOnce !== true) {
|
|
244
|
+
item._detailContent = _options.preTemplate(item);
|
|
245
|
+
} else {
|
|
246
|
+
_self.onAsyncResponse.notify({
|
|
247
|
+
"itemDetail": item,
|
|
248
|
+
"detailView": item._detailContent
|
|
249
|
+
}, undefined, this);
|
|
250
|
+
applyTemplateNewLineHeight(item);
|
|
251
|
+
_dataView.updateItem(item.id, item);
|
|
252
|
+
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
applyTemplateNewLineHeight(item);
|
|
257
|
+
_dataView.updateItem(item.id, item);
|
|
258
|
+
|
|
259
|
+
// async server call
|
|
260
|
+
_options.process(item);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* subscribe to the onAsyncResponse so that the plugin knows when the user server side calls finished
|
|
265
|
+
* the response has to be as "args.itemDetail" with it's data back
|
|
266
|
+
*/
|
|
267
|
+
function subscribeToOnAsyncResponse() {
|
|
268
|
+
_self.onAsyncResponse.subscribe(function (e, args) {
|
|
269
|
+
if (!args || !args.itemDetail) {
|
|
270
|
+
throw 'Slick.RowDetailView plugin requires the onAsyncResponse() to supply "args.itemDetail" property.'
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// If we just want to load in a view directly we can use detailView property to do so
|
|
274
|
+
if (args.detailView) {
|
|
275
|
+
args.itemDetail._detailContent = args.detailView;
|
|
276
|
+
} else {
|
|
277
|
+
args.itemDetail._detailContent = _options.postTemplate(args.itemDetail);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
args.itemDetail._detailViewLoaded = true;
|
|
281
|
+
|
|
282
|
+
var idxParent = _dataView.getIdxById(args.itemDetail.id);
|
|
283
|
+
_dataView.updateItem(args.itemDetail.id, args.itemDetail);
|
|
284
|
+
|
|
285
|
+
// trigger an event once the post template is finished loading
|
|
286
|
+
_self.onAsyncEndUpdate.notify({
|
|
287
|
+
"grid": _grid,
|
|
288
|
+
"itemDetail": args.itemDetail
|
|
289
|
+
}, e, _self);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function HandleAccordionShowHide(item) {
|
|
294
|
+
if (item) {
|
|
295
|
+
if (!item._collapsed) {
|
|
296
|
+
collapseItem(item);
|
|
297
|
+
} else {
|
|
298
|
+
expandItem(item);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
//////////////////////////////////////////////////////////////
|
|
304
|
+
//////////////////////////////////////////////////////////////
|
|
305
|
+
var getPaddingItem = function (parent, offset) {
|
|
306
|
+
var item = {};
|
|
307
|
+
|
|
308
|
+
for (var prop in _grid.getData()) {
|
|
309
|
+
item[prop] = null;
|
|
310
|
+
}
|
|
311
|
+
item.id = parent.id + "." + offset;
|
|
312
|
+
|
|
313
|
+
//additional hidden padding metadata fields
|
|
314
|
+
item._collapsed = true;
|
|
315
|
+
item._isPadding = true;
|
|
316
|
+
item._parent = parent;
|
|
317
|
+
item._offset = offset;
|
|
318
|
+
|
|
319
|
+
return item;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
//////////////////////////////////////////////////////////////
|
|
323
|
+
//create the detail ctr node. this belongs to the dev & can be custom-styled as per
|
|
324
|
+
//////////////////////////////////////////////////////////////
|
|
325
|
+
function applyTemplateNewLineHeight(item) {
|
|
326
|
+
// the height seems to be calculated by the template row count (how many line of items does the template have)
|
|
327
|
+
var rowCount = _options.panelRows;
|
|
328
|
+
|
|
329
|
+
//calculate padding requirements based on detail-content..
|
|
330
|
+
//ie. worst-case: create an invisible dom node now &find it's height.
|
|
331
|
+
var lineHeight = 13; //we know cuz we wrote the custom css innit ;)
|
|
332
|
+
item._sizePadding = Math.ceil(((rowCount * 2) * lineHeight) / _grid.getOptions().rowHeight);
|
|
333
|
+
item._height = (item._sizePadding * _grid.getOptions().rowHeight);
|
|
334
|
+
|
|
335
|
+
var idxParent = _dataView.getIdxById(item.id);
|
|
336
|
+
for (var idx = 1; idx <= item._sizePadding; idx++) {
|
|
337
|
+
_dataView.insertItem(idxParent + idx, getPaddingItem(item, idx));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
function getColumnDefinition() {
|
|
343
|
+
return {
|
|
344
|
+
id: _options.columnId,
|
|
345
|
+
name: "",
|
|
346
|
+
toolTip: _options.toolTip,
|
|
347
|
+
field: "sel",
|
|
348
|
+
width: _options.width,
|
|
349
|
+
resizable: false,
|
|
350
|
+
sortable: false,
|
|
351
|
+
cssClass: _options.cssClass,
|
|
352
|
+
formatter: detailSelectionFormatter
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function detailSelectionFormatter(row, cell, value, columnDef, dataContext) {
|
|
357
|
+
|
|
358
|
+
if (dataContext._collapsed == undefined) {
|
|
359
|
+
dataContext._collapsed = true,
|
|
360
|
+
dataContext._sizePadding = 0, //the required number of pading rows
|
|
361
|
+
dataContext._height = 0, //the actual height in pixels of the detail field
|
|
362
|
+
dataContext._isPadding = false,
|
|
363
|
+
dataContext._parent = undefined,
|
|
364
|
+
dataContext._offset = 0
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (dataContext._isPadding == true) {
|
|
368
|
+
//render nothing
|
|
369
|
+
} else if (dataContext._collapsed) {
|
|
370
|
+
return "<div class='detailView-toggle expand'></div>";
|
|
371
|
+
} else {
|
|
372
|
+
var html = [];
|
|
373
|
+
var rowHeight = _grid.getOptions().rowHeight;
|
|
374
|
+
var bottomMargin = 5;
|
|
375
|
+
|
|
376
|
+
//V313HAX:
|
|
377
|
+
//putting in an extra closing div after the closing toggle div and ommiting a
|
|
378
|
+
//final closing div for the detail ctr div causes the slickgrid renderer to
|
|
379
|
+
//insert our detail div as a new column ;) ~since it wraps whatever we provide
|
|
380
|
+
//in a generic div column container. so our detail becomes a child directly of
|
|
381
|
+
//the row not the cell. nice =) ~no need to apply a css change to the parent
|
|
382
|
+
//slick-cell to escape the cell overflow clipping.
|
|
383
|
+
|
|
384
|
+
//sneaky extra </div> inserted here-----------------v
|
|
385
|
+
html.push("<div class='detailView-toggle collapse'></div></div>");
|
|
386
|
+
|
|
387
|
+
html.push("<div id='cellDetailView_", dataContext.id, "' class='dynamic-cell-detail' "); //apply custom css to detail
|
|
388
|
+
html.push("style='height:", dataContext._height, "px;"); //set total height of padding
|
|
389
|
+
html.push("top:", rowHeight, "px'>"); //shift detail below 1st row
|
|
390
|
+
html.push("<div id='detailViewContainer_", dataContext.id, "' class='detail-container' style='max-height:" + (dataContext._height - rowHeight + bottomMargin) + "px'>"); //sub ctr for custom styling
|
|
391
|
+
html.push("<div id='innerDetailView_" , dataContext.id , "'>" , dataContext._detailContent, "</div></div>");
|
|
392
|
+
//&omit a final closing detail container </div> that would come next
|
|
393
|
+
|
|
394
|
+
return html.join("");
|
|
395
|
+
}
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function resizeDetailView(item) {
|
|
400
|
+
if (!item) return;
|
|
401
|
+
|
|
402
|
+
// Grad each of the dom items
|
|
403
|
+
var mainContainer = document.getElementById('detailViewContainer_' + item.id);
|
|
404
|
+
var cellItem = document.getElementById('cellDetailView_' + item.id);
|
|
405
|
+
var inner = document.getElementById('innerDetailView_' + item.id);
|
|
406
|
+
|
|
407
|
+
if (!mainContainer || !cellItem || !inner) return;
|
|
408
|
+
|
|
409
|
+
for (var idx = 1; idx <= item._sizePadding; idx++) {
|
|
410
|
+
_dataView.deleteItem(item.id + "." + idx);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
var rowHeight = _grid.getOptions().rowHeight; // height of a row
|
|
414
|
+
var lineHeight = 13; //we know cuz we wrote the custom css innit ;)
|
|
415
|
+
|
|
416
|
+
// Get the inner Item height as this will be the actual size
|
|
417
|
+
var itemHeight = inner.clientHeight;
|
|
418
|
+
|
|
419
|
+
// Now work out how many rows
|
|
420
|
+
var rowCount = Math.ceil(itemHeight / rowHeight) + 1;
|
|
421
|
+
|
|
422
|
+
item._sizePadding = Math.ceil(((rowCount * 2) * lineHeight) / rowHeight);
|
|
423
|
+
item._height = (item._sizePadding * rowHeight);
|
|
424
|
+
|
|
425
|
+
// If the padding is now more than the original minRowBuff we need to increase it
|
|
426
|
+
if (_grid.getOptions().minRowBuffer < item._sizePadding)
|
|
427
|
+
{
|
|
428
|
+
// Update the minRowBuffer so that the view doesn't disappear when it's at top of screen + the original default 3
|
|
429
|
+
_grid.getOptions().minRowBuffer =item._sizePadding + 3;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
mainContainer.setAttribute("style", "max-height: " + item._height + "px");
|
|
433
|
+
if (cellItem) cellItem.setAttribute("style", "height: " + item._height + "px;top:" + rowHeight + "px");
|
|
434
|
+
|
|
435
|
+
var idxParent = _dataView.getIdxById(item.id);
|
|
436
|
+
for (var idx = 1; idx <= item._sizePadding; idx++) {
|
|
437
|
+
_dataView.insertItem(idxParent + idx, getPaddingItem(item, idx));
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
$.extend(this, {
|
|
442
|
+
"init": init,
|
|
443
|
+
"destroy": destroy,
|
|
444
|
+
"collapseAll": collapseAll,
|
|
445
|
+
"getColumnDefinition": getColumnDefinition,
|
|
446
|
+
"getOptions": getOptions,
|
|
447
|
+
"setOptions": setOptions,
|
|
448
|
+
"onAsyncResponse": new Slick.Event(),
|
|
449
|
+
"onAsyncEndUpdate": new Slick.Event(),
|
|
450
|
+
"onAfterRowDetailToggle": new Slick.Event(),
|
|
451
|
+
"onBeforeRowDetailToggle": new Slick.Event(),
|
|
452
|
+
"resizeDetailView": resizeDetailView
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
})(jQuery);
|