@progress/kendo-angular-grid 21.0.0-develop.2 → 21.0.0-develop.3

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.
@@ -33,6 +33,7 @@ export declare class ColumnResizingService {
33
33
  }): () => void;
34
34
  measureColumns(info: Array<any>): void;
35
35
  autoFit(...columns: ColumnBase[]): void;
36
+ autoFitToGrid(gridEl: HTMLElement, scrollbarWidth: number, ...columns: ColumnBase[]): void;
36
37
  private trackColumns;
37
38
  private autoFitStart;
38
39
  private autoFitBatch;
@@ -4,8 +4,8 @@
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { Injectable, EventEmitter } from '@angular/core';
6
6
  import { zip } from 'rxjs';
7
- import { leafColumns } from '../columns/column-common';
8
7
  import { take } from 'rxjs/operators';
8
+ import { leafColumns } from '../columns/column-common';
9
9
  import * as i0 from "@angular/core";
10
10
  /**
11
11
  * @hidden
@@ -18,6 +18,21 @@ const resizeArgs = (column, extra) => Object.assign({
18
18
  columns: leafColumns([column]),
19
19
  locked: isLocked(column)
20
20
  }, extra);
21
+ /**
22
+ * @hidden
23
+ */
24
+ const measure = (col, gridEl) => {
25
+ const rowIndex = col.level + 1;
26
+ const selector = `tr[aria-rowindex="${rowIndex}"] > th[aria-colindex="${col.leafIndex + 1}"], tr[aria-rowindex="${rowIndex}"] > th[data-kendo-grid-column-index="${col.leafIndex}"]`;
27
+ const headerCell = gridEl.querySelector(selector);
28
+ if (headerCell) {
29
+ const headerCellWidth = headerCell.offsetWidth;
30
+ if (headerCellWidth > 0) {
31
+ return headerCellWidth;
32
+ }
33
+ }
34
+ return 0;
35
+ };
21
36
  /**
22
37
  * @hidden
23
38
  */
@@ -100,6 +115,45 @@ export class ColumnResizingService {
100
115
  }
101
116
  });
102
117
  }
118
+ autoFitToGrid(gridEl, scrollbarWidth, ...columns) {
119
+ const gridWidth = gridEl.clientWidth - scrollbarWidth - 1;
120
+ if (gridWidth <= 0) {
121
+ return;
122
+ }
123
+ const columnsWidths = columns.map(c => measure(c, gridEl));
124
+ const totalColumnsWidth = columnsWidths.reduce((sum, w) => sum + w, 0);
125
+ if (totalColumnsWidth === 0 || Math.abs(totalColumnsWidth - gridWidth) <= 1) {
126
+ return;
127
+ }
128
+ this.start(columns[0]);
129
+ const calculateNewWidths = (columnsWidths) => {
130
+ const totalWidth = columnsWidths.reduce((s, w) => s + w, 0);
131
+ const nonZeroColumns = columnsWidths.filter(w => w > 0).length;
132
+ const diff = (gridWidth - totalWidth) / nonZeroColumns;
133
+ const newWidths = columnsWidths.slice();
134
+ newWidths.forEach((w, i) => {
135
+ newWidths[i] = Math.max(0, w + diff);
136
+ });
137
+ return newWidths;
138
+ };
139
+ let newWidths = calculateNewWidths(columnsWidths);
140
+ const newTotal = newWidths.reduce((s, w) => s + w, 0);
141
+ if (newTotal !== gridWidth) {
142
+ newWidths = calculateNewWidths(newWidths);
143
+ }
144
+ columns.forEach((col, idx) => {
145
+ const oldWidth = columnsWidths[idx];
146
+ const newWidth = newWidths[idx];
147
+ col.width = newWidth;
148
+ this.resizedColumn({ column: col, oldWidth, newWidth });
149
+ });
150
+ const totalNew = newWidths.reduce((s, w) => s + w, 0);
151
+ const tableDelta = totalNew - totalColumnsWidth;
152
+ if (tableDelta < 0) {
153
+ this.resizeTable(columns[0], tableDelta);
154
+ }
155
+ this.end();
156
+ }
103
157
  trackColumns(column) {
104
158
  this.resizedColumns = [];
105
159
  this.column = column;
@@ -1693,6 +1693,24 @@ export class GridComponent {
1693
1693
  }
1694
1694
  this.columnResizingService.autoFit(...cols);
1695
1695
  }
1696
+ /**
1697
+ * Adjusts the width of the Grid columns to fit the entire Grid width.
1698
+ * - when the sum of all columns widths is less than the available Grid width&mdash;the available space is distributed evenly between all columns.
1699
+ * - when the sum of all columns widths is greater than the available Grid width&mdash;the columns are shrinked equally to fit the Grid width.
1700
+ *
1701
+ * Run this method after the Grid is populated with data.
1702
+ */
1703
+ autoFitColumnsToGrid() {
1704
+ const gridElement = this.wrapper.nativeElement;
1705
+ if (!gridElement) {
1706
+ return;
1707
+ }
1708
+ const leafColumns = this.columnsContainer.leafColumns.toArray();
1709
+ if (!leafColumns.length || leafColumns.length === 0) {
1710
+ return;
1711
+ }
1712
+ this.columnResizingService.autoFitToGrid(gridElement, this.scrollbarWidth, ...leafColumns);
1713
+ }
1696
1714
  /**
1697
1715
  * @hidden
1698
1716
  */
@@ -10,7 +10,7 @@ export const packageMetadata = {
10
10
  productName: 'Kendo UI for Angular',
11
11
  productCode: 'KENDOUIANGULAR',
12
12
  productCodes: ['KENDOUIANGULAR'],
13
- publishDate: 1761752966,
14
- version: '21.0.0-develop.2',
13
+ publishDate: 1761757848,
14
+ version: '21.0.0-develop.3',
15
15
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
16
16
  };
@@ -3251,6 +3251,21 @@ const resizeArgs = (column, extra) => Object.assign({
3251
3251
  columns: leafColumns([column]),
3252
3252
  locked: isLocked(column)
3253
3253
  }, extra);
3254
+ /**
3255
+ * @hidden
3256
+ */
3257
+ const measure = (col, gridEl) => {
3258
+ const rowIndex = col.level + 1;
3259
+ const selector = `tr[aria-rowindex="${rowIndex}"] > th[aria-colindex="${col.leafIndex + 1}"], tr[aria-rowindex="${rowIndex}"] > th[data-kendo-grid-column-index="${col.leafIndex}"]`;
3260
+ const headerCell = gridEl.querySelector(selector);
3261
+ if (headerCell) {
3262
+ const headerCellWidth = headerCell.offsetWidth;
3263
+ if (headerCellWidth > 0) {
3264
+ return headerCellWidth;
3265
+ }
3266
+ }
3267
+ return 0;
3268
+ };
3254
3269
  /**
3255
3270
  * @hidden
3256
3271
  */
@@ -3333,6 +3348,45 @@ class ColumnResizingService {
3333
3348
  }
3334
3349
  });
3335
3350
  }
3351
+ autoFitToGrid(gridEl, scrollbarWidth, ...columns) {
3352
+ const gridWidth = gridEl.clientWidth - scrollbarWidth - 1;
3353
+ if (gridWidth <= 0) {
3354
+ return;
3355
+ }
3356
+ const columnsWidths = columns.map(c => measure(c, gridEl));
3357
+ const totalColumnsWidth = columnsWidths.reduce((sum, w) => sum + w, 0);
3358
+ if (totalColumnsWidth === 0 || Math.abs(totalColumnsWidth - gridWidth) <= 1) {
3359
+ return;
3360
+ }
3361
+ this.start(columns[0]);
3362
+ const calculateNewWidths = (columnsWidths) => {
3363
+ const totalWidth = columnsWidths.reduce((s, w) => s + w, 0);
3364
+ const nonZeroColumns = columnsWidths.filter(w => w > 0).length;
3365
+ const diff = (gridWidth - totalWidth) / nonZeroColumns;
3366
+ const newWidths = columnsWidths.slice();
3367
+ newWidths.forEach((w, i) => {
3368
+ newWidths[i] = Math.max(0, w + diff);
3369
+ });
3370
+ return newWidths;
3371
+ };
3372
+ let newWidths = calculateNewWidths(columnsWidths);
3373
+ const newTotal = newWidths.reduce((s, w) => s + w, 0);
3374
+ if (newTotal !== gridWidth) {
3375
+ newWidths = calculateNewWidths(newWidths);
3376
+ }
3377
+ columns.forEach((col, idx) => {
3378
+ const oldWidth = columnsWidths[idx];
3379
+ const newWidth = newWidths[idx];
3380
+ col.width = newWidth;
3381
+ this.resizedColumn({ column: col, oldWidth, newWidth });
3382
+ });
3383
+ const totalNew = newWidths.reduce((s, w) => s + w, 0);
3384
+ const tableDelta = totalNew - totalColumnsWidth;
3385
+ if (tableDelta < 0) {
3386
+ this.resizeTable(columns[0], tableDelta);
3387
+ }
3388
+ this.end();
3389
+ }
3336
3390
  trackColumns(column) {
3337
3391
  this.resizedColumns = [];
3338
3392
  this.column = column;
@@ -22842,8 +22896,8 @@ const packageMetadata = {
22842
22896
  productName: 'Kendo UI for Angular',
22843
22897
  productCode: 'KENDOUIANGULAR',
22844
22898
  productCodes: ['KENDOUIANGULAR'],
22845
- publishDate: 1761752966,
22846
- version: '21.0.0-develop.2',
22899
+ publishDate: 1761757848,
22900
+ version: '21.0.0-develop.3',
22847
22901
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
22848
22902
  };
22849
22903
 
@@ -31220,6 +31274,24 @@ class GridComponent {
31220
31274
  }
31221
31275
  this.columnResizingService.autoFit(...cols);
31222
31276
  }
31277
+ /**
31278
+ * Adjusts the width of the Grid columns to fit the entire Grid width.
31279
+ * - when the sum of all columns widths is less than the available Grid width&mdash;the available space is distributed evenly between all columns.
31280
+ * - when the sum of all columns widths is greater than the available Grid width&mdash;the columns are shrinked equally to fit the Grid width.
31281
+ *
31282
+ * Run this method after the Grid is populated with data.
31283
+ */
31284
+ autoFitColumnsToGrid() {
31285
+ const gridElement = this.wrapper.nativeElement;
31286
+ if (!gridElement) {
31287
+ return;
31288
+ }
31289
+ const leafColumns = this.columnsContainer.leafColumns.toArray();
31290
+ if (!leafColumns.length || leafColumns.length === 0) {
31291
+ return;
31292
+ }
31293
+ this.columnResizingService.autoFitToGrid(gridElement, this.scrollbarWidth, ...leafColumns);
31294
+ }
31223
31295
  /**
31224
31296
  * @hidden
31225
31297
  */
@@ -899,6 +899,14 @@ export declare class GridComponent implements AfterContentInit, AfterViewInit, O
899
899
  * [See example](slug:resizing_columns_grid#toc-auto-fitting-the-content)
900
900
  */
901
901
  autoFitColumns(columns?: Array<ColumnBase> | QueryList<ColumnBase>): void;
902
+ /**
903
+ * Adjusts the width of the Grid columns to fit the entire Grid width.
904
+ * - when the sum of all columns widths is less than the available Grid width&mdash;the available space is distributed evenly between all columns.
905
+ * - when the sum of all columns widths is greater than the available Grid width&mdash;the columns are shrinked equally to fit the Grid width.
906
+ *
907
+ * Run this method after the Grid is populated with data.
908
+ */
909
+ autoFitColumnsToGrid(): void;
902
910
  /**
903
911
  * @hidden
904
912
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progress/kendo-angular-grid",
3
- "version": "21.0.0-develop.2",
3
+ "version": "21.0.0-develop.3",
4
4
  "description": "Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "Progress",
@@ -41,7 +41,7 @@
41
41
  "package": {
42
42
  "productName": "Kendo UI for Angular",
43
43
  "productCode": "KENDOUIANGULAR",
44
- "publishDate": 1761752966,
44
+ "publishDate": 1761757848,
45
45
  "licensingDocsUrl": "https://www.telerik.com/kendo-angular-ui/my-license/"
46
46
  }
47
47
  },
@@ -54,32 +54,32 @@
54
54
  "@progress/kendo-data-query": "^1.0.0",
55
55
  "@progress/kendo-drawing": "^1.21.0",
56
56
  "@progress/kendo-licensing": "^1.7.0",
57
- "@progress/kendo-angular-buttons": "21.0.0-develop.2",
58
- "@progress/kendo-angular-common": "21.0.0-develop.2",
59
- "@progress/kendo-angular-dateinputs": "21.0.0-develop.2",
60
- "@progress/kendo-angular-layout": "21.0.0-develop.2",
61
- "@progress/kendo-angular-navigation": "21.0.0-develop.2",
62
- "@progress/kendo-angular-dropdowns": "21.0.0-develop.2",
63
- "@progress/kendo-angular-excel-export": "21.0.0-develop.2",
64
- "@progress/kendo-angular-icons": "21.0.0-develop.2",
65
- "@progress/kendo-angular-indicators": "21.0.0-develop.2",
66
- "@progress/kendo-angular-inputs": "21.0.0-develop.2",
67
- "@progress/kendo-angular-conversational-ui": "21.0.0-develop.2",
68
- "@progress/kendo-angular-intl": "21.0.0-develop.2",
69
- "@progress/kendo-angular-l10n": "21.0.0-develop.2",
70
- "@progress/kendo-angular-label": "21.0.0-develop.2",
71
- "@progress/kendo-angular-menu": "21.0.0-develop.2",
72
- "@progress/kendo-angular-pager": "21.0.0-develop.2",
73
- "@progress/kendo-angular-pdf-export": "21.0.0-develop.2",
74
- "@progress/kendo-angular-popup": "21.0.0-develop.2",
75
- "@progress/kendo-angular-toolbar": "21.0.0-develop.2",
76
- "@progress/kendo-angular-upload": "21.0.0-develop.2",
77
- "@progress/kendo-angular-utils": "21.0.0-develop.2",
57
+ "@progress/kendo-angular-buttons": "21.0.0-develop.3",
58
+ "@progress/kendo-angular-common": "21.0.0-develop.3",
59
+ "@progress/kendo-angular-dateinputs": "21.0.0-develop.3",
60
+ "@progress/kendo-angular-layout": "21.0.0-develop.3",
61
+ "@progress/kendo-angular-navigation": "21.0.0-develop.3",
62
+ "@progress/kendo-angular-dropdowns": "21.0.0-develop.3",
63
+ "@progress/kendo-angular-excel-export": "21.0.0-develop.3",
64
+ "@progress/kendo-angular-icons": "21.0.0-develop.3",
65
+ "@progress/kendo-angular-indicators": "21.0.0-develop.3",
66
+ "@progress/kendo-angular-inputs": "21.0.0-develop.3",
67
+ "@progress/kendo-angular-conversational-ui": "21.0.0-develop.3",
68
+ "@progress/kendo-angular-intl": "21.0.0-develop.3",
69
+ "@progress/kendo-angular-l10n": "21.0.0-develop.3",
70
+ "@progress/kendo-angular-label": "21.0.0-develop.3",
71
+ "@progress/kendo-angular-menu": "21.0.0-develop.3",
72
+ "@progress/kendo-angular-pager": "21.0.0-develop.3",
73
+ "@progress/kendo-angular-pdf-export": "21.0.0-develop.3",
74
+ "@progress/kendo-angular-popup": "21.0.0-develop.3",
75
+ "@progress/kendo-angular-toolbar": "21.0.0-develop.3",
76
+ "@progress/kendo-angular-upload": "21.0.0-develop.3",
77
+ "@progress/kendo-angular-utils": "21.0.0-develop.3",
78
78
  "rxjs": "^6.5.3 || ^7.0.0"
79
79
  },
80
80
  "dependencies": {
81
81
  "tslib": "^2.3.1",
82
- "@progress/kendo-angular-schematics": "21.0.0-develop.2",
82
+ "@progress/kendo-angular-schematics": "21.0.0-develop.3",
83
83
  "@progress/kendo-common": "^1.0.1",
84
84
  "@progress/kendo-file-saver": "^1.0.0"
85
85
  },
@@ -5,19 +5,19 @@ const schematics_1 = require("@angular-devkit/schematics");
5
5
  function default_1(options) {
6
6
  const finalOptions = Object.assign(Object.assign({}, options), { mainNgModule: 'GridModule', package: 'grid', peerDependencies: {
7
7
  // peer deps of the dropdowns
8
- '@progress/kendo-angular-treeview': '21.0.0-develop.2',
9
- '@progress/kendo-angular-navigation': '21.0.0-develop.2',
8
+ '@progress/kendo-angular-treeview': '21.0.0-develop.3',
9
+ '@progress/kendo-angular-navigation': '21.0.0-develop.3',
10
10
  // peer dependency of kendo-angular-inputs
11
- '@progress/kendo-angular-dialog': '21.0.0-develop.2',
11
+ '@progress/kendo-angular-dialog': '21.0.0-develop.3',
12
12
  // peer dependency of kendo-angular-icons
13
13
  '@progress/kendo-svg-icons': '^4.0.0',
14
14
  // peer dependency of kendo-angular-layout
15
- '@progress/kendo-angular-progressbar': '21.0.0-develop.2',
15
+ '@progress/kendo-angular-progressbar': '21.0.0-develop.3',
16
16
  // transitive peer dependencies from toolbar
17
- '@progress/kendo-angular-indicators': '21.0.0-develop.2',
17
+ '@progress/kendo-angular-indicators': '21.0.0-develop.3',
18
18
  // transitive peer dependencies from conversational-ui
19
- '@progress/kendo-angular-menu': '21.0.0-develop.2',
20
- '@progress/kendo-angular-upload': '21.0.0-develop.2'
19
+ '@progress/kendo-angular-menu': '21.0.0-develop.3',
20
+ '@progress/kendo-angular-upload': '21.0.0-develop.3'
21
21
  } });
22
22
  return (0, schematics_1.externalSchematic)('@progress/kendo-angular-schematics', 'ng-add', finalOptions);
23
23
  }