Skip to content

Commit 342c20f

Browse files
feat: non resizable columns functionality in table (#813)
* feat: non resizable columns functionality in table
1 parent bc0622b commit 342c20f

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

projects/components/src/table/table.component.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,15 @@ $header-height: 32px;
8181
.header-column-resize-handle {
8282
padding: 6px 2px;
8383
height: 100%;
84-
cursor: col-resize;
8584

86-
&:hover {
87-
padding: 0 2px;
85+
&.resizable {
86+
cursor: col-resize;
87+
&:hover {
88+
padding: 0 2px;
8889

89-
.header-column-divider {
90-
background-color: $gray-9;
90+
.header-column-divider {
91+
background-color: $gray-9;
92+
}
9193
}
9294
}
9395

projects/components/src/table/table.component.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import { TableColumnConfigExtended, TableService } from './table.service';
8080
<div
8181
*ngIf="index !== 0"
8282
class="header-column-resize-handle"
83+
[ngClass]="{ resizable: this.resizable }"
8384
(mousedown)="this.onResizeMouseDown($event, index)"
8485
>
8586
<div class="header-column-divider"></div>
@@ -247,6 +248,9 @@ export class TableComponent
247248
@Input()
248249
public pageable?: boolean = true;
249250

251+
@Input()
252+
public resizable?: boolean = true;
253+
250254
@Input()
251255
public detailContent?: TemplateRef<{ row: StatefulTableRow }>;
252256

@@ -426,15 +430,17 @@ export class TableComponent
426430
}
427431

428432
public onResizeMouseDown(event: MouseEvent, index: number): void {
429-
this.resizeHeaderOffsetLeft = this.headerRowElement.nativeElement.offsetLeft;
433+
if (this.resizable) {
434+
this.resizeHeaderOffsetLeft = this.headerRowElement.nativeElement.offsetLeft;
430435

431-
this.resizeColumns = {
432-
left: this.buildColumnInfo(index - 1),
433-
right: this.buildColumnInfo(index)
434-
};
436+
this.resizeColumns = {
437+
left: this.buildColumnInfo(index - 1),
438+
right: this.buildColumnInfo(index)
439+
};
435440

436-
this.resizeStartX = event.clientX;
437-
event.preventDefault();
441+
this.resizeStartX = event.clientX;
442+
event.preventDefault();
443+
}
438444
}
439445

440446
@HostListener('mousemove', ['$event'])

projects/distributed-tracing/src/shared/dashboard/widgets/table/table-widget-base.model.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ export abstract class TableWidgetBaseModel extends BaseModel {
104104
})
105105
public pageable: boolean = true;
106106

107+
@ModelProperty({
108+
key: 'resizable',
109+
displayName: 'Resizable',
110+
type: BOOLEAN_PROPERTY.type
111+
})
112+
public resizable: boolean = true;
113+
107114
@ModelInject(MODEL_API)
108115
protected readonly api!: ModelApi;
109116

@@ -157,4 +164,8 @@ export abstract class TableWidgetBaseModel extends BaseModel {
157164
public isPageable(): boolean {
158165
return this.pageable;
159166
}
167+
168+
public isResizable(): boolean {
169+
return this.resizable;
170+
}
160171
}

projects/distributed-tracing/src/shared/dashboard/widgets/table/table-widget-renderer.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import { TableWidgetModel } from './table-widget.model';
7878
[filters]="this.combinedFilters$ | async"
7979
[queryProperties]="this.queryProperties$ | async"
8080
[pageable]="this.api.model.isPageable()"
81+
[resizable]="this.api.model.isResizable()"
8182
[detailContent]="childDetail"
8283
[syncWithUrl]="this.syncWithUrl"
8384
(selectionsChange)="this.onRowSelection($event)"

0 commit comments

Comments
 (0)