Skip to content

feat: non resizable columns functionality in table #813

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 2 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
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
12 changes: 7 additions & 5 deletions projects/components/src/table/table.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ $header-height: 32px;
.header-column-resize-handle {
padding: 6px 2px;
height: 100%;
cursor: col-resize;

&:hover {
padding: 0 2px;
&.resizable {
cursor: col-resize;
&:hover {
padding: 0 2px;

.header-column-divider {
background-color: $gray-9;
.header-column-divider {
background-color: $gray-9;
}
}
}

Expand Down
20 changes: 13 additions & 7 deletions projects/components/src/table/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import { TableColumnConfigExtended, TableService } from './table.service';
<div
*ngIf="index !== 0"
class="header-column-resize-handle"
[ngClass]="{ resizable: this.resizable }"
(mousedown)="this.onResizeMouseDown($event, index)"
>
<div class="header-column-divider"></div>
Expand Down Expand Up @@ -247,6 +248,9 @@ export class TableComponent
@Input()
public pageable?: boolean = true;

@Input()
public resizable?: boolean = true;

@Input()
public detailContent?: TemplateRef<{ row: StatefulTableRow }>;

Expand Down Expand Up @@ -426,15 +430,17 @@ export class TableComponent
}

public onResizeMouseDown(event: MouseEvent, index: number): void {
this.resizeHeaderOffsetLeft = this.headerRowElement.nativeElement.offsetLeft;
if (this.resizable) {
this.resizeHeaderOffsetLeft = this.headerRowElement.nativeElement.offsetLeft;

this.resizeColumns = {
left: this.buildColumnInfo(index - 1),
right: this.buildColumnInfo(index)
};
this.resizeColumns = {
left: this.buildColumnInfo(index - 1),
right: this.buildColumnInfo(index)
};

this.resizeStartX = event.clientX;
event.preventDefault();
this.resizeStartX = event.clientX;
event.preventDefault();
}
}

@HostListener('mousemove', ['$event'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ export abstract class TableWidgetBaseModel extends BaseModel {
})
public pageable: boolean = true;

@ModelProperty({
key: 'resizable',
displayName: 'Resizable',
type: BOOLEAN_PROPERTY.type
})
public resizable: boolean = true;

@ModelInject(MODEL_API)
protected readonly api!: ModelApi;

Expand Down Expand Up @@ -157,4 +164,8 @@ export abstract class TableWidgetBaseModel extends BaseModel {
public isPageable(): boolean {
return this.pageable;
}

public isResizable(): boolean {
return this.resizable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import { TableWidgetModel } from './table-widget.model';
[filters]="this.combinedFilters$ | async"
[queryProperties]="this.queryProperties$ | async"
[pageable]="this.api.model.isPageable()"
[resizable]="this.api.model.isResizable()"
[detailContent]="childDetail"
[syncWithUrl]="this.syncWithUrl"
(selectionsChange)="this.onRowSelection($event)"
Expand Down