jquery.dgtable 0.5.52 → 0.5.55
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 +9 -2
- package/dist/jquery.dgtable.cjs.js +29 -16
- package/dist/jquery.dgtable.cjs.js.map +1 -1
- package/dist/jquery.dgtable.cjs.min.js +2 -2
- package/dist/jquery.dgtable.cjs.min.js.map +1 -1
- package/dist/jquery.dgtable.es6.js +29 -16
- package/dist/jquery.dgtable.es6.js.map +1 -1
- package/dist/jquery.dgtable.es6.min.js +2 -2
- package/dist/jquery.dgtable.es6.min.js.map +1 -1
- package/dist/jquery.dgtable.umd.js +42 -29
- package/dist/jquery.dgtable.umd.js.map +1 -1
- package/dist/jquery.dgtable.umd.min.js +2 -2
- package/dist/jquery.dgtable.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +17 -8
- package/src/row_collection.js +11 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* jquery.dgtable 0.5.
|
|
2
|
+
* jquery.dgtable 0.5.55
|
|
3
3
|
* git://github.com/danielgindi/jquery.dgtable.git
|
|
4
4
|
*/
|
|
5
5
|
import jQuery from 'jquery';
|
|
@@ -1342,13 +1342,15 @@ function getDefaultComparator(column, descending) {
|
|
|
1342
1342
|
|
|
1343
1343
|
/**
|
|
1344
1344
|
* @param {Boolean=false} silent
|
|
1345
|
-
* @returns {
|
|
1345
|
+
* @returns {Function|undefined} the comparator that was used
|
|
1346
1346
|
*/
|
|
1347
1347
|
RowCollection.prototype.sort = function (silent) {
|
|
1348
|
+
let comparator;
|
|
1349
|
+
|
|
1348
1350
|
if (this.sortColumn.length) {
|
|
1349
|
-
let comparators = []
|
|
1351
|
+
let comparators = [];
|
|
1350
1352
|
|
|
1351
|
-
for (i = 0; i < this.sortColumn.length; i++) {
|
|
1353
|
+
for (let i = 0; i < this.sortColumn.length; i++) {
|
|
1352
1354
|
comparator = null;
|
|
1353
1355
|
const defaultComparator = getDefaultComparator(this.sortColumn[i], this.sortColumn[i].descending);
|
|
1354
1356
|
if (this.onComparatorRequired) {
|
|
@@ -1361,13 +1363,14 @@ RowCollection.prototype.sort = function (silent) {
|
|
|
1361
1363
|
}
|
|
1362
1364
|
|
|
1363
1365
|
if (comparators.length === 1) {
|
|
1364
|
-
|
|
1366
|
+
comparator = comparators[0];
|
|
1367
|
+
nativeSort.call(this, comparator);
|
|
1365
1368
|
} else {
|
|
1366
1369
|
let len = comparators.length,
|
|
1367
1370
|
value;
|
|
1368
1371
|
|
|
1369
1372
|
comparator = function (leftRow, rightRow) {
|
|
1370
|
-
for (i = 0; i < len; i++) {
|
|
1373
|
+
for (let i = 0; i < len; i++) {
|
|
1371
1374
|
value = comparators[i](leftRow, rightRow);
|
|
1372
1375
|
if (value !== 0) {
|
|
1373
1376
|
return value;
|
|
@@ -1381,11 +1384,12 @@ RowCollection.prototype.sort = function (silent) {
|
|
|
1381
1384
|
|
|
1382
1385
|
if (!silent) {
|
|
1383
1386
|
if (this.onSort) {
|
|
1384
|
-
this.onSort();
|
|
1387
|
+
this.onSort(comparator);
|
|
1385
1388
|
}
|
|
1386
1389
|
}
|
|
1387
1390
|
}
|
|
1388
|
-
|
|
1391
|
+
|
|
1392
|
+
return comparator;
|
|
1389
1393
|
};
|
|
1390
1394
|
|
|
1391
1395
|
function ColumnCollection() {
|
|
@@ -2469,6 +2473,7 @@ DGTable.prototype.renderRows = function (first, last) {
|
|
|
2469
2473
|
|
|
2470
2474
|
let tableClassName = o.tableClassName,
|
|
2471
2475
|
rowClassName = tableClassName + '-row',
|
|
2476
|
+
altRowClassName = tableClassName + '-row-alt',
|
|
2472
2477
|
cellClassName = tableClassName + '-cell',
|
|
2473
2478
|
rows = p.filteredRows || p.rows,
|
|
2474
2479
|
isDataFiltered = !!p.filteredRows,
|
|
@@ -2477,8 +2482,7 @@ DGTable.prototype.renderRows = function (first, last) {
|
|
|
2477
2482
|
isVirtual = o.virtualTable,
|
|
2478
2483
|
virtualRowHeightFirst = p.virtualRowHeightFirst,
|
|
2479
2484
|
virtualRowHeight = p.virtualRowHeight,
|
|
2480
|
-
top
|
|
2481
|
-
physicalRowIndex;
|
|
2485
|
+
top;
|
|
2482
2486
|
|
|
2483
2487
|
let colCount = visibleColumns.length;
|
|
2484
2488
|
for (let colIndex = 0, column; colIndex < colCount; colIndex++) {
|
|
@@ -2498,10 +2502,13 @@ DGTable.prototype.renderRows = function (first, last) {
|
|
|
2498
2502
|
i++) {
|
|
2499
2503
|
|
|
2500
2504
|
let rowData = rows[i];
|
|
2501
|
-
physicalRowIndex = isDataFiltered ? rowData['__i'] : i;
|
|
2505
|
+
let physicalRowIndex = isDataFiltered ? rowData['__i'] : i;
|
|
2502
2506
|
|
|
2503
2507
|
let row = createElement('div');
|
|
2504
2508
|
row.className = rowClassName;
|
|
2509
|
+
if (i % 2 === 1)
|
|
2510
|
+
row.className += ' ' + altRowClassName;
|
|
2511
|
+
|
|
2505
2512
|
row['rowIndex'] = i;
|
|
2506
2513
|
row['physicalRowIndex'] = physicalRowIndex;
|
|
2507
2514
|
|
|
@@ -2539,6 +2546,11 @@ DGTable.prototype.renderRows = function (first, last) {
|
|
|
2539
2546
|
bodyFragment.appendChild(row);
|
|
2540
2547
|
|
|
2541
2548
|
this.trigger('rowcreate', i, physicalRowIndex, row, rowData);
|
|
2549
|
+
|
|
2550
|
+
let rowIndex = i;
|
|
2551
|
+
row.addEventListener('click', (event) => {
|
|
2552
|
+
this.trigger('rowclick', event, rowIndex, physicalRowIndex, row, rowData);
|
|
2553
|
+
});
|
|
2542
2554
|
}
|
|
2543
2555
|
|
|
2544
2556
|
return bodyFragment;
|
|
@@ -3039,8 +3051,9 @@ DGTable.prototype.sort = function (column, descending, add) {
|
|
|
3039
3051
|
|
|
3040
3052
|
p.rows.sortColumn = currentSort;
|
|
3041
3053
|
|
|
3054
|
+
let comparator;
|
|
3042
3055
|
if (currentSort.length) {
|
|
3043
|
-
p.rows.sort(!!p.filteredRows);
|
|
3056
|
+
comparator = p.rows.sort(!!p.filteredRows);
|
|
3044
3057
|
if (p.filteredRows) {
|
|
3045
3058
|
p.filteredRows.sort(!!p.filteredRows);
|
|
3046
3059
|
}
|
|
@@ -3051,7 +3064,7 @@ DGTable.prototype.sort = function (column, descending, add) {
|
|
|
3051
3064
|
for (let i = 0; i < currentSort.length; i++) {
|
|
3052
3065
|
sorts.push({ 'column': currentSort[i].column, 'descending': currentSort[i].descending });
|
|
3053
3066
|
}
|
|
3054
|
-
this.trigger('sort', sorts, true /* direct sort
|
|
3067
|
+
this.trigger('sort', sorts, true /* direct sort */, comparator);
|
|
3055
3068
|
|
|
3056
3069
|
return this;
|
|
3057
3070
|
};
|
|
@@ -3075,9 +3088,10 @@ DGTable.prototype.resort = function () {
|
|
|
3075
3088
|
}
|
|
3076
3089
|
}
|
|
3077
3090
|
|
|
3091
|
+
let comparator;
|
|
3078
3092
|
p.rows.sortColumn = currentSort;
|
|
3079
3093
|
if (currentSort.length) {
|
|
3080
|
-
p.rows.sort(!!p.filteredRows);
|
|
3094
|
+
comparator = p.rows.sort(!!p.filteredRows);
|
|
3081
3095
|
if (p.filteredRows) {
|
|
3082
3096
|
p.filteredRows.sort(!!p.filteredRows);
|
|
3083
3097
|
}
|
|
@@ -3088,10 +3102,9 @@ DGTable.prototype.resort = function () {
|
|
|
3088
3102
|
for (let i = 0; i < currentSort.length; i++) {
|
|
3089
3103
|
sorts.push({ 'column': currentSort[i].column, 'descending': currentSort[i].descending });
|
|
3090
3104
|
}
|
|
3091
|
-
this.trigger('sort', sorts, false /* indirect sort
|
|
3105
|
+
this.trigger('sort', sorts, false /* indirect sort */, comparator);
|
|
3092
3106
|
}
|
|
3093
3107
|
|
|
3094
|
-
|
|
3095
3108
|
return this;
|
|
3096
3109
|
};
|
|
3097
3110
|
|