jquery.dgtable 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -73,7 +73,7 @@ To create a new table, just use `var myTable = new DGTable(INIT_OPTIONS)`.
73
73
  * `DGTable.Width.AUTO`: Sets the width automatically
74
74
  * `DGTable.Width.SCROLL`: Creates a horizontal scroll when required
75
75
  * **virtualTable**: `boolean=true` When set, the table will work in virtual mode, which means only the visible rows are rendered. Rows must have fixed height in this mode.
76
- * **estimatedRowHeight**: `number=40` Sets the estimated row height for the table. This is used for virtual table mode, to calculate the estimated scroll size.
76
+ * **estimatedRowHeight**: `number?` Sets the estimated row height for the table. This is used for virtual table mode, to calculate the estimated scroll size. Will be auto calculated by default.
77
77
  * **resizableColumns**: `boolean=true` Turns on or off the resizable columns globally.
78
78
  * **movableColumns**: `boolean=true` Turns on or off the movable columns globally.
79
79
  * **sortableColumns**: `number=1` How many columns can you sort by, one after another?
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * jquery.dgtable 0.6.0
2
+ * jquery.dgtable 0.6.1
3
3
  * git://github.com/danielgindi/jquery.dgtable.git
4
4
  */
5
5
  'use strict';
@@ -3219,7 +3219,7 @@ DGTable.prototype.initialize = function (options) {
3219
3219
  /**
3220
3220
  * @private
3221
3221
  * @field {number} estimatedRowHeight */
3222
- o.estimatedRowHeight = options.estimatedRowHeight === undefined ? 40 : options.estimatedRowHeight;
3222
+ o.estimatedRowHeight = options.estimatedRowHeight || undefined;
3223
3223
 
3224
3224
  /**
3225
3225
  * @private
@@ -3481,7 +3481,7 @@ DGTable.prototype._setupVirtualTable = function () {
3481
3481
  autoVirtualWrapperWidth: false,
3482
3482
  virtual: true,
3483
3483
  buffer: o.rowsBufferSize,
3484
- estimatedItemHeight: o.estimatedRowHeight || 40,
3484
+ estimatedItemHeight: o.estimatedRowHeight ? o.estimatedRowHeight : p.virtualRowHeight || 40,
3485
3485
  itemElementCreatorFn: () => {
3486
3486
  return createElement('div');
3487
3487
  },
@@ -6417,6 +6417,41 @@ DGTable.prototype._renderSkeletonBody = function () {
6417
6417
 
6418
6418
  let tableClassName = o.tableClassName;
6419
6419
 
6420
+ // Calculate virtual row heights
6421
+ if (o.virtualTable && !p.virtualRowHeight) {
6422
+ let createDummyRow = function () {
6423
+ let row = createElement('div'),
6424
+ cell = row.appendChild(createElement('div')),
6425
+ cellInner = cell.appendChild(createElement('div'));
6426
+ row.className = tableClassName + '-row';
6427
+ cell.className = tableClassName + '-cell';
6428
+ cellInner.innerHTML = '0';
6429
+ row.style.visibility = 'hidden';
6430
+ row.style.position = 'absolute';
6431
+ return row;
6432
+ };
6433
+
6434
+ let $dummyTbody,$dummyWrapper = $('<div>').
6435
+ addClass(that.el.className).
6436
+ css({ 'z-index': -1, 'position': 'absolute', left: '0', top: '-9999px', width: '1px', overflow: 'hidden' }).
6437
+ append(
6438
+ $('<div>').addClass(tableClassName).append(
6439
+ $dummyTbody = $('<div>').addClass(tableClassName + '-body').css('width', 99999)));
6440
+
6441
+
6442
+
6443
+ $dummyWrapper.appendTo(document.body);
6444
+
6445
+ let row1 = createDummyRow(),row2 = createDummyRow(),row3 = createDummyRow();
6446
+ $dummyTbody.append(row1, row2, row3);
6447
+
6448
+ p.virtualRowHeightFirst = Css.getElementHeight(row1, true, true, true);
6449
+ p.virtualRowHeight = Css.getElementHeight(row2, true, true, true);
6450
+ p.virtualRowHeightLast = Css.getElementHeight(row3, true, true, true);
6451
+
6452
+ $dummyWrapper.remove();
6453
+ }
6454
+
6420
6455
  // Create inner table and tbody
6421
6456
  if (!p.$table) {
6422
6457