Angular UI Components Documentation
The Angular DockPanel allows the creation of dock layouts. This guide adds the Angular DockPanel (jqxDockPanel) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-ngjqwidgets-ng/jqxdockpanel In an Angular project (to start one, see Getting started with Angular), add the package with the Angular CLI. It asks for a theme and adds the styles to angular.json:
ng add jqwidgets-ng
Components are standalone: add jqxDockPanelModule to the imports of the component that uses it.
import { Component } from '@angular/core';
import { jqxDockPanelModule } from 'jqwidgets-ng/jqxdockpanel';
@Component({
selector: 'app-root',
imports: [jqxDockPanelModule],
templateUrl: './app.html'
})
export class App {}
The source of the live Overview demo.
<div style="width: 300px; font-size: 13px; font-family: Verdana;">
<jqxDockPanel #myDockPanel style="color: #fff;" [width]="300" [height]="210">
<div #first dock="left" style="background: #486974;">First Div</div>
<div #second dock="top" style="height: 100px; background: #368ba7;">Second Div</div>
<div #third dock="right" style="background: #df7169;">Third Div</div>
<div #fourth style="background: #a73654;">Fourth Div</div>
</jqxDockPanel>
<br />
<div>Layout Types:</div>
<div (click)="layoutOnClick($event)" style="cursor: pointer;">
<img title="click to apply a new layout" alt="layout types" src="https://www.jqwidgets.com/angular/images/LayoutTypes.png" />
</div>
<br />
<div>Spiral:</div>
<jqxDockPanel style="color: #fff;" [width]="300" [height]="210" [lastchildfill]="false">
<div dock="left" style="width: 20px; height: 20px; background: #486974;">1</div>
<div dock="top" style="width: 20px; height: 20px; background: #368ba7;">2</div>
<div dock="right" style="width: 20px; height: 20px; background: #df7169;">3</div>
<div dock="bottom" style="width: 20px; height: 20px; background: #a73654;">4</div>
</jqxDockPanel>
</div>
import { Component, ElementRef, viewChild } from '@angular/core';
import { jqxDockPanelComponent, jqxDockPanelModule } from 'jqwidgets-ng/jqxdockpanel';
@Component({ imports: [jqxDockPanelModule], selector: 'app-root', templateUrl: './app.html' })
export class App {
readonly myDockPanel = viewChild.required<jqxDockPanelComponent>('myDockPanel');
readonly first = viewChild.required<ElementRef<HTMLElement>>('first');
readonly second = viewChild.required<ElementRef<HTMLElement>>('second');
readonly third = viewChild.required<ElementRef<HTMLElement>>('third');
readonly fourth = viewChild.required<ElementRef<HTMLElement>>('fourth');
// Applies a layout depending on which of the pictured layouts was clicked.
layoutOnClick(event: MouseEvent): void {
const first = this.first().nativeElement;
const second = this.second().nativeElement;
const third = this.third().nativeElement;
const fourth = this.fourth().nativeElement;
const all = [first, second, third, fourth];
const size = (width: string, height: string) =>
all.forEach((div) => {
div.style.width = width;
div.style.height = height;
});
const position = event.clientX - (event.target as HTMLElement).getBoundingClientRect().left;
size('auto', 'auto');
if (position < 55) {
first.setAttribute('dock', 'bottom');
first.style.height = '105px';
second.setAttribute('dock', 'left');
second.style.width = '100px';
third.setAttribute('dock', 'left');
third.style.width = '100px';
fourth.setAttribute('dock', 'left');
fourth.style.width = '100px';
} else if (position < 115) {
size('100px', 'auto');
first.setAttribute('dock', 'left');
second.setAttribute('dock', 'right');
third.setAttribute('dock', 'bottom');
third.style.height = '140px';
fourth.setAttribute('dock', 'top');
fourth.style.height = '70px';
} else if (position < 175) {
size('150px', 'auto');
all.forEach((div) => div.setAttribute('dock', 'left'));
} else if (position < 235) {
size('auto', '70px');
all.forEach((div) => div.setAttribute('dock', 'top'));
} else {
size('100px', 'auto');
all.forEach((div) => div.setAttribute('dock', 'left'));
}
this.myDockPanel().refresh();
}
}
Options are inputs, bound with [name]="value".
Events are outputs named on plus the event name with a capital first letter. For example, layout: Occurs when the layout is performed.
<jqxDockPanel (onLayout)="onLayout($event)"></jqxDockPanel>
onLayout(event: any): void {
console.log(event.args);
}
Get the component with a signal query and call its methods. For example, refresh: Refreshes the DockPanel.
<jqxDockPanel #myDockPanel></jqxDockPanel>
import { Component, viewChild } from '@angular/core';
import { jqxDockPanelModule, jqxDockPanelComponent } from 'jqwidgets-ng/jqxdockpanel';
@Component({
selector: 'app-root',
imports: [jqxDockPanelModule],
templateUrl: './app.html'
})
export class App {
readonly myDockPanel = viewChild.required<jqxDockPanelComponent>('myDockPanel');
run(): void {
this.myDockPanel().refresh();
}
}