Skip to content

feat(GridBase): Apply spec for server-side rendering for relative gri… #15556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@ All notable changes for each version of this project will be documented in this
- **Deprecation** - `tabIndex` has been deprecated and will be removed in a future version.
- `IgxGrid`, `IgxHierarchicalGrid`, `IgxTreeGrid`
- A column's `minWidth` and `maxWidth` constrain the user-specified `width` so that it cannot go outside their bounds.
- In SSR mode grid with height 100% or with no height will render on the server with % size and with no data. The grid will show either the empty grid template or the loading indicator (if isLoading is true).
- In SSR mode grid with width 100% or with no width will render on the server with % size and with all columns.

## 19.1.1
### New Features
19 changes: 17 additions & 2 deletions projects/igniteui-angular/src/lib/grids/grid-base.directive.ts
Original file line number Diff line number Diff line change
@@ -3364,12 +3364,26 @@ export abstract class IgxGridBaseDirective implements GridType,
private get hasZeroResultFilter(): boolean {
return this.filteredData && this.filteredData.length === 0;
}
protected get totalCalcWidth() {
return this.platform.isBrowser ? this.calcWidth : undefined;
}

protected get renderData() {
// omit data if not in the browser and size is %
return !this.platform.isBrowser && this.isPercentHeight ? undefined : this.data;
}

@HostBinding('style.display')
protected displayStyle = 'grid';

@HostBinding('style.grid-template-rows')
protected templateRows = 'auto auto auto 1fr auto auto';

/**
* @hidden @internal
*/
private get hasNoData(): boolean {
return !this.data || this.dataLength === 0;
return !this.data || this.dataLength === 0 || !this.platform.isBrowser;
}

/**
@@ -5169,7 +5183,8 @@ export abstract class IgxGridBaseDirective implements GridType,

/** @hidden @internal */
public get totalHeight() {
return this.calcHeight ? this.calcHeight + this.pinnedRowHeight : this.calcHeight;
const height = this.calcHeight ? this.calcHeight + this.pinnedRowHeight : this.calcHeight;
return this.platform.isBrowser ? height : undefined;
}

/**
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
<div class="igx-grid__tbody-content" tabindex="0" [attr.role]="dataView.length ? null : 'row'" (keydown)="navigation.handleNavigation($event)" (focus)="navigation.focusTbody($event)"
(dragStop)="selectionService.dragMode = $event" (scroll)="preventContainerScroll($event)"
(dragScroll)="dragScroll($event)" [igxGridDragSelect]="selectionService.dragMode"
[style.height.px]="totalHeight" [style.width.px]="calcWidth || null" #tbody [attr.aria-activedescendant]="activeDescendant">
[style.height.px]="totalHeight" [style.width.px]="totalCalcWidth" [style.width]="!platform.isBrowser ? '100%' : undefined" #tbody [attr.aria-activedescendant]="activeDescendant">
@if (moving && columnInDrag && pinnedColumns.length <= 0) {
<span
[igxColumnMovingDrop]="headerContainer" [attr.droppable]="true" id="left"
@@ -70,7 +70,7 @@
}
}
</ng-template>
<ng-template igxGridFor let-rowData [igxGridForOf]="data
<ng-template igxGridFor let-rowData [igxGridForOf]="renderData
| gridTransaction:id:pipeTrigger
| visibleColumns:hasVisibleColumns
| gridFiltering:filteringExpressionsTree:filterStrategy:advancedFilteringExpressionsTree:id:pipeTrigger:filteringPipeTrigger
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
<div class="igx-grid__tbody-content" tabindex="0" (focus)="navigation.focusTbody($event)"
(keydown)="navigation.handleNavigation($event)" (dragStop)="selectionService.dragMode = $event"
(dragScroll)="dragScroll($event)" [igxGridDragSelect]="selectionService.dragMode" [attr.aria-activedescendant]="activeDescendant" [attr.role]="dataView.length ? null : 'row'"
[style.height.px]="totalHeight" [style.width.px]="calcWidth" #tbody (scroll)="preventContainerScroll($event)">
[style.height.px]="totalHeight" [style.width.px]="totalCalcWidth" [style.width]="!platform.isBrowser ? '100%' : undefined" #tbody (scroll)="preventContainerScroll($event)">
@if (moving && columnInDrag && pinnedColumns.length <= 0) {
<span
[igxColumnMovingDrop]="headerContainer" [attr.droppable]="true" id="left"
@@ -54,7 +54,7 @@
</ng-template>
<ng-container *ngTemplateOutlet="hasPinnedRecords && isRowPinningToTop ? pinnedRecordsTemplate : null">
</ng-container>
<ng-template igxGridFor let-rowData let-rowIndex="index" [igxGridForOf]="data
<ng-template igxGridFor let-rowData let-rowIndex="index" [igxGridForOf]="renderData
| gridTransaction:id:pipeTrigger
| visibleColumns:hasVisibleColumns
| gridFiltering:filteringExpressionsTree:filterStrategy:advancedFilteringExpressionsTree:id:pipeTrigger:filteringPipeTrigger
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
<div class="igx-grid__tbody-content" tabindex="0" [attr.role]="dataView.length ? null : 'row'" (keydown)="navigation.handleNavigation($event)" (focus)="navigation.focusTbody($event)"
(dragStop)="selectionService.dragMode = $event" (scroll)="preventContainerScroll($event)"
(dragScroll)="dragScroll($event)" [igxGridDragSelect]="selectionService.dragMode"
[style.height.px]="totalHeight" [style.width.px]="pivotContentCalcWidth || null" #tbody [attr.aria-activedescendant]="activeDescendant">
[style.height.px]="totalHeight" [style.width.px]="pivotContentCalcWidth || null" [style.width]="!platform.isBrowser ? '100%' : undefined" #tbody [attr.aria-activedescendant]="activeDescendant">
@if (hasMovableColumns && columnInDrag && pinnedColumns.length <= 0) {
<span [igxColumnMovingDrop]="headerContainer" [attr.droppable]="true" id="left"
class="igx-grid__scroll-on-drag-left"></span>
@@ -31,7 +31,7 @@
<span [igxColumnMovingDrop]="headerContainer" [attr.droppable]="true" id="left"
class="igx-grid__scroll-on-drag-pinned" [style.left.px]="pinnedWidth"></span>
}
<ng-template igxGridFor let-rowData [igxGridForOf]="data
<ng-template igxGridFor let-rowData [igxGridForOf]="renderData
| pivotGridFilter:pivotConfiguration:filterStrategy:advancedFilteringExpressionsTree:filteringPipeTrigger:pipeTrigger
| pivotGridSort:pivotConfiguration:sortStrategy:pipeTrigger
| pivotGridRow:pivotConfiguration:pivotValueCloneStrategy:expansionStates:pipeTrigger:sortingExpressions
Original file line number Diff line number Diff line change
@@ -1290,6 +1290,9 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni

/** @hidden @internal */
public get pivotContentCalcWidth() {
if (!this.platform.isBrowser) {
return undefined;
}
if (!this.visibleRowDimensions.length) {
return Math.max(0, this.calcWidth - this.pivotRowWidths);
}
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
<div class="igx-grid__tbody-content" tabindex="0" (focus)="navigation.focusTbody($event)" (keydown)="navigation.handleNavigation($event)"
(dragStop)="selectionService.dragMode = $event" [attr.aria-activedescendant]="activeDescendant" [attr.role]="dataView.length ? null : 'row'"
(dragScroll)="dragScroll($event)" [igxGridDragSelect]="selectionService.dragMode"
[style.height.px]='totalHeight' [style.width.px]='calcWidth' #tbody (scroll)='preventContainerScroll($event)'>
[style.height.px]='totalHeight' [style.width.px]="totalCalcWidth" [style.width]="!platform.isBrowser ? '100%' : undefined" #tbody (scroll)='preventContainerScroll($event)'>
@if (moving && columnInDrag && pinnedColumns.length <= 0) {
<span
[igxColumnMovingDrop]="headerContainer" [attr.droppable]="true" id="left"
@@ -56,7 +56,7 @@
}
</ng-template>
<ng-container *ngTemplateOutlet="hasPinnedRecords && isRowPinningToTop ? pinnedRecordsTemplate : null"></ng-container>
<ng-template igxGridFor let-rowData [igxGridForOf]="data
<ng-template igxGridFor let-rowData [igxGridForOf]="renderData
| treeGridTransaction:pipeTrigger
| visibleColumns:hasVisibleColumns
| treeGridHierarchizing:primaryKey:foreignKey:childDataKey:pipeTrigger

Unchanged files with check annotations Beta

this.colsWidth = event.target.value;
}
public onColEnter(event: IDropBaseEventArgs, rowIndex, colIndex) {

Check warning on line 170 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (20.x)

'event' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 170 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (22.x)

'event' is defined but never used. Allowed unused args must match /^_/u
this.collection[rowIndex][colIndex].hovered = true;
}
public onColLeave(event: IDropBaseEventArgs, rowIndex, colIndex) {

Check warning on line 174 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (20.x)

'event' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 174 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (22.x)

'event' is defined but never used. Allowed unused args must match /^_/u
this.collection[rowIndex][colIndex].hovered = false;
}
this.resizeVisible = true;
}
public onBlur(event, rowIndex, colIndex) {

Check warning on line 235 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (20.x)

'event' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 235 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (22.x)

'event' is defined but never used. Allowed unused args must match /^_/u
this.cellSelected = null;
this.collection[rowIndex][colIndex].selected = false;
this.resizeVisible = false;
event.target.setPointerCapture(event.pointerId);
}
public pointerMoveResizeLeft(event, cellRef, rowIndex, colIndex) {

Check warning on line 250 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (20.x)

'rowIndex' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 250 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (22.x)

'rowIndex' is defined but never used. Allowed unused args must match /^_/u
if (this.dragStarted) {
const curDistance = this.dragStartX - event.pageX;
const minIncrease = -this.curResizedCell.colSpan;
}
}
public pointerMoveResizeRight(event, cellRef, rowIndex, colIndex) {

Check warning on line 262 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (20.x)

'rowIndex' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 262 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (20.x)

'cellRef' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 262 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (22.x)

'rowIndex' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 262 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (22.x)

'cellRef' is defined but never used. Allowed unused args must match /^_/u
if (this.dragStarted) {
const curDistance = event.pageX - this.dragStartX;
const maxIncrease = this.colsCount - (colIndex + this.curResizedCell.colSpan);
}
}
public pointerUpResizeRight(event, cellRef, rowIndex, colIndex) {

Check warning on line 271 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (20.x)

'cellRef' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 271 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (20.x)

'event' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 271 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (22.x)

'cellRef' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 271 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (22.x)

'event' is defined but never used. Allowed unused args must match /^_/u
this.dragStarted = false;
this.resizeVisible = false;
this.colSpanIncrease = 0;
}
public pointerUpResizeLeft(event, cellRef, targetRowIndex, targetColIndex) {

Check warning on line 351 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (20.x)

'event' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 351 in src/app/grid-multi-row-layout-config/grid-mrl-config.sample.ts

GitHub Actions / run-tests (22.x)

'event' is defined but never used. Allowed unused args must match /^_/u
this.dragStarted = false;
this.resizeVisible = false;
return `${this.remoteService.url}?$count=true&$skip=${state.startIndex}&$top=${chunkSize}`;
};
// eslint-disable-next-line prefer-spread
this.localItems = Array.apply(null, { length: 2000 }).map((e, i) => ({

Check warning on line 41 in src/app/drop-down/drop-down-virtual/drop-down-virtual.component.ts

GitHub Actions / run-tests (20.x)

'e' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 41 in src/app/drop-down/drop-down-virtual/drop-down-virtual.component.ts

GitHub Actions / run-tests (22.x)

'e' is defined but never used. Allowed unused args must match /^_/u
name: `Item ${i + 1}`,
id: i
}));