diff --git a/src/app/showcase/doc/treetable/basicdoc.ts b/src/app/showcase/doc/treetable/basicdoc.ts index 3c81eafe7ec..5064119b525 100644 --- a/src/app/showcase/doc/treetable/basicdoc.ts +++ b/src/app/showcase/doc/treetable/basicdoc.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -9,35 +9,37 @@ import { NodeService } from '../../service/nodeservice';

TreeTable requires a collection of TreeNode instances as a value components as children for the representation.

- - - - Name - Size - Type - - - - - - - {{ rowData.name }} - - {{ rowData.size }} - {{ rowData.type }} - - - + + + + + Name + Size + Type + + + + + + + {{ rowData.name }} + + {{ rowData.size }} + {{ rowData.type }} + + + +
`, changeDetection: ChangeDetectionStrategy.OnPush }) -export class BasicDoc implements OnInit { +export class BasicDoc { files!: TreeNode[]; constructor(private nodeService: NodeService, private cd: ChangeDetectorRef) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => { this.files = files.slice(0, 5); this.cd.markForCheck(); diff --git a/src/app/showcase/doc/treetable/columngroupdoc.ts b/src/app/showcase/doc/treetable/columngroupdoc.ts index c5f30251eb6..93cfa4a7929 100644 --- a/src/app/showcase/doc/treetable/columngroupdoc.ts +++ b/src/app/showcase/doc/treetable/columngroupdoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; @@ -6,51 +6,54 @@ import { Code } from '../../domain/code'; selector: 'column-group-doc', template: `
- - - - Brand - Sale Rate - - - Sales - Profits - - - Last Year - This Year - Last Year - This Year - - - - - - - {{ rowData.brand }} - - {{ rowData.lastYearSale }} - {{ rowData.thisYearSale }} - {{ rowData.lastYearProfit }} - {{ rowData.thisYearProfit }} - - - - - Totals - $3,283,772 - $2,126,925 - - - + + + + + Brand + Sale Rate + + + Sales + Profits + + + Last Year + This Year + Last Year + This Year + + + + + + + {{ rowData.brand }} + + {{ rowData.lastYearSale }} + {{ rowData.thisYearSale }} + {{ rowData.lastYearProfit }} + {{ rowData.thisYearProfit }} + + + + + Totals + $3,283,772 + $2,126,925 + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class ColumnGroupDoc implements OnInit { +export class ColumnGroupDoc { sales!: TreeNode[]; - ngOnInit() { + loadDemoData() { this.sales = [ { data: { brand: 'Bliss', lastYearSale: '51%', thisYearSale: '40%', lastYearProfit: '$54,406.00', thisYearProfit: '$43,342' }, diff --git a/src/app/showcase/doc/treetable/columnresizeexpanddoc.ts b/src/app/showcase/doc/treetable/columnresizeexpanddoc.ts index 15b5e6788c5..a906b0c81ea 100644 --- a/src/app/showcase/doc/treetable/columnresizeexpanddoc.ts +++ b/src/app/showcase/doc/treetable/columnresizeexpanddoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,35 +15,38 @@ interface Column {

Setting columnResizeMode as expand changes the table width as well.

- - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class ResizeExpandDoc implements OnInit { +export class ResizeExpandDoc { files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, diff --git a/src/app/showcase/doc/treetable/columnresizefitdoc.ts b/src/app/showcase/doc/treetable/columnresizefitdoc.ts index 53912fdaee6..087dba58736 100644 --- a/src/app/showcase/doc/treetable/columnresizefitdoc.ts +++ b/src/app/showcase/doc/treetable/columnresizefitdoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,6 +15,7 @@ interface Column {

Columns can be resized with drag and drop when resizableColumns is enabled. Default resize mode is fit that does not change the overall table width.

+ @@ -32,18 +33,20 @@ interface Column { +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class ResizeFitDoc implements OnInit { +export class ResizeFitDoc { files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, diff --git a/src/app/showcase/doc/treetable/columnresizescrollabledoc.ts b/src/app/showcase/doc/treetable/columnresizescrollabledoc.ts index f2941374e85..a6f3eab9485 100644 --- a/src/app/showcase/doc/treetable/columnresizescrollabledoc.ts +++ b/src/app/showcase/doc/treetable/columnresizescrollabledoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,40 +15,43 @@ interface Column {

To utilize the column resize modes with a scrollable TreeTable, a colgroup template must be defined. The default value of scrollHeight is "flex," it can also be set as a string value.

- - - - - - - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class ResizeScrollableDoc implements OnInit { +export class ResizeScrollableDoc { files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, diff --git a/src/app/showcase/doc/treetable/columntoggledoc.ts b/src/app/showcase/doc/treetable/columntoggledoc.ts index 98b5f776256..019e54459a1 100644 --- a/src/app/showcase/doc/treetable/columntoggledoc.ts +++ b/src/app/showcase/doc/treetable/columntoggledoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,33 +15,36 @@ interface Column {

Column visibility based on a condition can be implemented with dynamic columns, in this sample a MultiSelect is used to manage the visible columns.

- - -
- -
-
- - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - -
+ + + +
+ +
+
+ + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + +
+
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class ColumnToggleDoc implements OnInit { +export class ColumnToggleDoc { files!: TreeNode[]; cols!: Column[]; @@ -50,7 +53,7 @@ export class ColumnToggleDoc implements OnInit { constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ diff --git a/src/app/showcase/doc/treetable/conditionalstyledoc.ts b/src/app/showcase/doc/treetable/conditionalstyledoc.ts index 1af9ba4dfe1..d393d6c39dc 100644 --- a/src/app/showcase/doc/treetable/conditionalstyledoc.ts +++ b/src/app/showcase/doc/treetable/conditionalstyledoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,35 +15,38 @@ interface Column {

Particular rows and cells can be styled based on conditions. The ngClass receives a row data as a parameter to return a style class for a row whereas cells are customized using the body template.

- - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class ConditionalStyleDoc implements OnInit { +export class ConditionalStyleDoc { files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, diff --git a/src/app/showcase/doc/treetable/contextmenudoc.ts b/src/app/showcase/doc/treetable/contextmenudoc.ts index 8cbd54bcf53..9a8c033f9ca 100644 --- a/src/app/showcase/doc/treetable/contextmenudoc.ts +++ b/src/app/showcase/doc/treetable/contextmenudoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MenuItem, MessageService, TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -16,32 +16,33 @@ interface Column {
- - - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - - + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + +
`, - providers: [MessageService] + providers: [MessageService], + changeDetection: ChangeDetectionStrategy.OnPush }) -export class ContextMenuDoc implements OnInit { +export class ContextMenuDoc { files!: TreeNode[]; selectedNode!: TreeNode; @@ -52,7 +53,7 @@ export class ContextMenuDoc implements OnInit { constructor(private nodeService: NodeService, private messageService: MessageService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ diff --git a/src/app/showcase/doc/treetable/controlleddoc.ts b/src/app/showcase/doc/treetable/controlleddoc.ts new file mode 100644 index 00000000000..4c5e10cadc5 --- /dev/null +++ b/src/app/showcase/doc/treetable/controlleddoc.ts @@ -0,0 +1,136 @@ +import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core'; +import { TreeNode } from 'primeng/api'; +import { Code } from '../../domain/code'; +import { NodeService } from '../../service/nodeservice'; + +@Component({ + selector: 'controlled-doc', + template: ` +

Expansion state is controlled with expandedKeys property. The expandedKeys should be an object whose keys refer to the node key and values represent the expanded state e.g. {'0-0': true}.

+
+
+ + + + + + Name + Size + Type + + + + + + + {{ rowData.name }} + + {{ rowData.size }} + {{ rowData.type }} + + + + +
+ `, + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class ControlledDoc { + files!: TreeNode[]; + + constructor(private nodeService: NodeService, private cd: ChangeDetectorRef) {} + + loadDemoData() { + this.nodeService.getFilesystem().then((files) => { + this.files = files.slice(0, 5); + this.cd.markForCheck(); + }); + } + + toggleApplications() { + if (this.files && this.files.length > 0) { + const newFiles = [...this.files]; + newFiles[0] = { ...newFiles[0], expanded: !newFiles[0].expanded }; + this.files = newFiles; + } + } + + code: Code = { + basic: ` + + + + Name + Size + Type + + + + + + + {{ rowData.name }} + + {{ rowData.size }} + {{ rowData.type }} + + +`, + + html: `
+ + + + + Name + Size + Type + + + + + + + {{ rowData.name }} + + {{ rowData.size }} + {{ rowData.type }} + + + +
`, + + typescript: ` +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; +import { TreeNode } from 'primeng/api'; +import { NodeService } from '../../service/nodeservice'; + + +@Component({ + selector: 'tree-table-controlled-demo', + templateUrl: './tree-table-controlled-demo.html' +}) +export class TreeTableControlledDemo implements OnInit { + files!: TreeNode[]; + + constructor(private nodeService: NodeService, private cd: ChangeDetectorRef) {} + + ngOnInit() { + this.nodeService.getFilesystem().then((files) => { + this.files = files.slice(0, 5); + this.cd.markForCheck(); + }); + } + + toggleApplications() { + if (this.files && this.files.length > 0) { + const newFiles = [...this.files]; + newFiles[0] = { ...newFiles[0], expanded: !newFiles[0].expanded }; + this.files = newFiles; + } + } +}`, + + service: ['NodeService'] + }; +} diff --git a/src/app/showcase/doc/treetable/dynamiccolumnsdoc.ts b/src/app/showcase/doc/treetable/dynamiccolumnsdoc.ts index 30d0ecdf073..a4ba0fe3fe3 100644 --- a/src/app/showcase/doc/treetable/dynamiccolumnsdoc.ts +++ b/src/app/showcase/doc/treetable/dynamiccolumnsdoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,35 +15,40 @@ interface Column {

Columns can be created programmatically.

- - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + +
- ` + + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class DynamicColumnsDoc implements OnInit { +export class DynamicColumnsDoc { + files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, @@ -51,7 +56,6 @@ export class DynamicColumnsDoc implements OnInit { { field: 'type', header: 'Type' } ]; } - code: Code = { basic: ` diff --git a/src/app/showcase/doc/treetable/editdoc.ts b/src/app/showcase/doc/treetable/editdoc.ts index 0d3118213f1..66bf4608747 100644 --- a/src/app/showcase/doc/treetable/editdoc.ts +++ b/src/app/showcase/doc/treetable/editdoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,40 +15,43 @@ interface Column {

Incell editing is enabled by defining input elements with treeTableCellEditor.

- - - - - {{ col.header }} - - - - - - - - - - - - {{ rowData[col.field] }} - - - - - + + + + + + {{ col.header }} + + + + + + + + + + + + {{ rowData[col.field] }} + + + + + +
` + ,changeDetection: ChangeDetectionStrategy.OnPush }) -export class EditDoc implements OnInit { +export class EditDoc { files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, diff --git a/src/app/showcase/doc/treetable/filterdoc.ts b/src/app/showcase/doc/treetable/filterdoc.ts index 2d7e7b1664b..e31d39a2de5 100644 --- a/src/app/showcase/doc/treetable/filterdoc.ts +++ b/src/app/showcase/doc/treetable/filterdoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -21,6 +21,7 @@ interface Column {
+
@@ -52,15 +53,17 @@ interface Column { - No data found. + No data found. +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class FilterDoc implements OnInit { +export class FilterDoc { filterMode = 'lenient'; filterModes = [ @@ -74,7 +77,7 @@ export class FilterDoc implements OnInit { constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, diff --git a/src/app/showcase/doc/treetable/gridlinesdoc.ts b/src/app/showcase/doc/treetable/gridlinesdoc.ts index 4d0b8e0bc0c..12762a929b4 100644 --- a/src/app/showcase/doc/treetable/gridlinesdoc.ts +++ b/src/app/showcase/doc/treetable/gridlinesdoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -10,35 +10,38 @@ import { NodeService } from '../../service/nodeservice';

Adding p-treetable-gridlines class displays grid lines.

- - - - Name - Size - Type - - - - - - - {{ rowData.name }} - - {{ rowData.size }} - {{ rowData.type }} - - - + + + + + Name + Size + Type + + + + + + + {{ rowData.name }} + + {{ rowData.size }} + {{ rowData.type }} + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class GridlinesDoc implements OnInit { +export class GridlinesDoc { files!: TreeNode[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); } diff --git a/src/app/showcase/doc/treetable/lazyloaddoc.ts b/src/app/showcase/doc/treetable/lazyloaddoc.ts index e6858722776..c84c270db93 100644 --- a/src/app/showcase/doc/treetable/lazyloaddoc.ts +++ b/src/app/showcase/doc/treetable/lazyloaddoc.ts @@ -1,4 +1,4 @@ -import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -54,7 +54,8 @@ interface Column {
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) export class LazyLoadDoc implements OnInit { files!: TreeNode[]; @@ -127,6 +128,7 @@ export class LazyLoadDoc implements OnInit { ]; this.files = [...this.files]; + this.cd.markForCheck(); }, 250); } @@ -255,6 +257,7 @@ export class TreeTableLazyLoadDemo implements OnInit{ ]; this.files = [...this.files]; + this.cd.markForCheck(); }, 250); } }`, diff --git a/src/app/showcase/doc/treetable/paginatorbasicdoc.ts b/src/app/showcase/doc/treetable/paginatorbasicdoc.ts index 88a78404452..03fb3483a21 100644 --- a/src/app/showcase/doc/treetable/paginatorbasicdoc.ts +++ b/src/app/showcase/doc/treetable/paginatorbasicdoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; @@ -10,32 +10,34 @@ interface Column { @Component({ selector: 'paginator-basic-doc', template: `
- - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class PaginatorBasicDoc implements OnInit { +export class PaginatorBasicDoc { files!: TreeNode[]; cols!: Column[]; - - ngOnInit() { + loadDemoData() { this.files = []; for (let i = 0; i < 50; i++) { let node = { diff --git a/src/app/showcase/doc/treetable/paginatorlocaledoc.ts b/src/app/showcase/doc/treetable/paginatorlocaledoc.ts index 1ef3fa50274..fed44fa4d34 100644 --- a/src/app/showcase/doc/treetable/paginatorlocaledoc.ts +++ b/src/app/showcase/doc/treetable/paginatorlocaledoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; @@ -14,33 +14,36 @@ interface Column {

paginator localization information such as page numbers and rows per page options are defined with the paginatorLocale property which defaults to the user locale.

- - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class PaginatorLocaleDoc implements OnInit { +export class PaginatorLocaleDoc { files!: TreeNode[]; cols!: Column[]; - ngOnInit() { + loadDemoData() { this.files = []; for (let i = 0; i < 50; i++) { let node = { diff --git a/src/app/showcase/doc/treetable/paginatortemplatedoc.ts b/src/app/showcase/doc/treetable/paginatortemplatedoc.ts index 4e75fc931e7..8918b091864 100644 --- a/src/app/showcase/doc/treetable/paginatortemplatedoc.ts +++ b/src/app/showcase/doc/treetable/paginatortemplatedoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; @@ -17,40 +17,43 @@ interface Column {

- - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - - - - - - - - + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + + + + + + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class PaginatorTemplateDoc implements OnInit { +export class PaginatorTemplateDoc { files!: TreeNode[]; cols!: Column[]; - ngOnInit() { + loadDemoData() { this.files = []; for (let i = 0; i < 50; i++) { let node = { diff --git a/src/app/showcase/doc/treetable/reorderdoc.ts b/src/app/showcase/doc/treetable/reorderdoc.ts index 21ffaa4327d..f92baf3d02e 100644 --- a/src/app/showcase/doc/treetable/reorderdoc.ts +++ b/src/app/showcase/doc/treetable/reorderdoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,35 +15,38 @@ interface Column {

Order of the columns can be changed using drag and drop when reorderableColumns is present.

- - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + + +
- - ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class ReorderDoc implements OnInit { +export class ReorderDoc { files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, diff --git a/src/app/showcase/doc/treetable/scrollfrozencolumnsdoc.ts b/src/app/showcase/doc/treetable/scrollfrozencolumnsdoc.ts index f0cc1023a8a..f19fd127f86 100644 --- a/src/app/showcase/doc/treetable/scrollfrozencolumnsdoc.ts +++ b/src/app/showcase/doc/treetable/scrollfrozencolumnsdoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,40 +15,44 @@ interface Column {

A column can be fixed during horizontal scrolling by enabling the frozenColumns property.

- - - - - - - - - - {{ col.header }} - - - - - - - {{ rowData[col.field] }} - - - - - - - - {{ rowData.name }} - - - - + + + + + + + + + + + {{ col.header }} + + + + + + + {{ rowData[col.field] }} + + + + + + + + {{ rowData.name }} + + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush + }) -export class FrozenColumnsDoc implements OnInit { +export class FrozenColumnsDoc { files!: TreeNode[]; cols!: Column[]; @@ -59,7 +63,7 @@ export class FrozenColumnsDoc implements OnInit { constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, diff --git a/src/app/showcase/doc/treetable/scrollhorizontaldoc.ts b/src/app/showcase/doc/treetable/scrollhorizontaldoc.ts index b99da88c65a..7f60ce0da51 100644 --- a/src/app/showcase/doc/treetable/scrollhorizontaldoc.ts +++ b/src/app/showcase/doc/treetable/scrollhorizontaldoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,40 +15,42 @@ interface Column {

Horizontal scrolling is enabled when the total width of columns exceeds table width.

- - - - - - - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + +
` }) -export class ScrollHorizontalDoc implements OnInit { +export class ScrollHorizontalDoc { files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, diff --git a/src/app/showcase/doc/treetable/scrollverticaldoc.ts b/src/app/showcase/doc/treetable/scrollverticaldoc.ts index b813a765951..90de479227b 100644 --- a/src/app/showcase/doc/treetable/scrollverticaldoc.ts +++ b/src/app/showcase/doc/treetable/scrollverticaldoc.ts @@ -1,7 +1,6 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; -import { AppDocSectionTextComponent } from '../../layout/doc/app.docsectiontext.component'; import { NodeService } from '../../service/nodeservice'; interface Column { @@ -16,35 +15,38 @@ interface Column {

Adding scrollable property along with a scrollHeight for the data viewport enables vertical scrolling with fixed headers.

- - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class ScrollVerticalDoc implements OnInit { +export class ScrollVerticalDoc { files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, diff --git a/src/app/showcase/doc/treetable/selectioncheckboxdoc.ts b/src/app/showcase/doc/treetable/selectioncheckboxdoc.ts index b96e696ef78..5d8f7ebf83b 100644 --- a/src/app/showcase/doc/treetable/selectioncheckboxdoc.ts +++ b/src/app/showcase/doc/treetable/selectioncheckboxdoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -16,35 +16,38 @@ interface Column {

In checkbox selection mode, value binding should be a key-value pair where key is the node key and value is an object that has checked and partialChecked properties to represent the checked state of a node.

- - -
- - Toggle All -
-
- - - - {{ col.header }} - - - - - - - - - {{ rowData[col.field] }} - - - -
+ + + +
+ + Toggle All +
+
+ + + + {{ col.header }} + + + + + + + + + {{ rowData[col.field] }} + + + +
+
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class SelectionCheckboxDoc implements OnInit { +export class SelectionCheckboxDoc { files!: TreeNode[]; selectedNodes!: TreeNode[]; @@ -53,7 +56,7 @@ export class SelectionCheckboxDoc implements OnInit { constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ diff --git a/src/app/showcase/doc/treetable/selectioneventscdoc.ts b/src/app/showcase/doc/treetable/selectioneventscdoc.ts index 066280489b4..588073e724d 100644 --- a/src/app/showcase/doc/treetable/selectioneventscdoc.ts +++ b/src/app/showcase/doc/treetable/selectioneventscdoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MessageService, TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -21,6 +21,7 @@ interface NodeEvent {
+ +
`, - providers: [MessageService] + providers: [MessageService], + changeDetection: ChangeDetectionStrategy.OnPush }) -export class SelectionEventsDoc implements OnInit { +export class SelectionEventsDoc { files!: TreeNode[]; selectedNode!: TreeNode; @@ -62,7 +65,7 @@ export class SelectionEventsDoc implements OnInit { constructor(private nodeService: NodeService, private messageService: MessageService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ diff --git a/src/app/showcase/doc/treetable/selectionmultipledoc.ts b/src/app/showcase/doc/treetable/selectionmultipledoc.ts index d21af18f339..1ff25153271 100644 --- a/src/app/showcase/doc/treetable/selectionmultipledoc.ts +++ b/src/app/showcase/doc/treetable/selectionmultipledoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -23,6 +23,7 @@ interface Column { Metakey + @@ -40,11 +41,13 @@ interface Column { + - ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class SelectionMultipleDoc implements OnInit { +export class SelectionMultipleDoc { metaKeySelection: boolean = true; files!: TreeNode[]; @@ -55,7 +58,7 @@ export class SelectionMultipleDoc implements OnInit { constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ diff --git a/src/app/showcase/doc/treetable/selectionsingledoc.ts b/src/app/showcase/doc/treetable/selectionsingledoc.ts index 2fdf6c6931e..e9d628625eb 100644 --- a/src/app/showcase/doc/treetable/selectionsingledoc.ts +++ b/src/app/showcase/doc/treetable/selectionsingledoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -23,28 +23,31 @@ interface Column { Metakey - - - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + + - ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class SelectionSingleDoc implements OnInit { +export class SelectionSingleDoc { metaKeySelection: boolean = true; files!: TreeNode[]; @@ -55,7 +58,7 @@ export class SelectionSingleDoc implements OnInit { constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ diff --git a/src/app/showcase/doc/treetable/sizedoc.ts b/src/app/showcase/doc/treetable/sizedoc.ts index 9382cf13ff2..e4af5fe7314 100644 --- a/src/app/showcase/doc/treetable/sizedoc.ts +++ b/src/app/showcase/doc/treetable/sizedoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -13,30 +13,33 @@ import { NodeService } from '../../service/nodeservice';
- - - - Name - Size - Type - - - - - - - {{ rowData.name }} - - {{ rowData.size }} - {{ rowData.type }} - - - + + + + + Name + Size + Type + + + + + + + {{ rowData.name }} + + {{ rowData.size }} + {{ rowData.type }} + + + + - ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class SizeDoc implements OnInit { +export class SizeDoc { files!: TreeNode[]; sizes!: any[]; @@ -45,7 +48,7 @@ export class SizeDoc implements OnInit { constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.sizes = [ diff --git a/src/app/showcase/doc/treetable/sortmultiplecolumndoc.ts b/src/app/showcase/doc/treetable/sortmultiplecolumndoc.ts index 701a585d063..ad515268691 100644 --- a/src/app/showcase/doc/treetable/sortmultiplecolumndoc.ts +++ b/src/app/showcase/doc/treetable/sortmultiplecolumndoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,36 +15,39 @@ interface Column {

Multiple columns can be sorted by defining sortMode as multiple. This mode requires metaKey (e.g. ) to be pressed when clicking a header.

- - - - - {{ col.header }} - - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + {{ col.header }} + + + + + + + + + {{ rowData[col.field] }} + + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class SortMultipleColumnDoc implements OnInit { +export class SortMultipleColumnDoc { files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ diff --git a/src/app/showcase/doc/treetable/sortsinglecolumndoc.ts b/src/app/showcase/doc/treetable/sortsinglecolumndoc.ts index 78b443fa9ed..b5bb657c741 100644 --- a/src/app/showcase/doc/treetable/sortsinglecolumndoc.ts +++ b/src/app/showcase/doc/treetable/sortsinglecolumndoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,36 +15,39 @@ interface Column {

Sorting on a column is enabled by adding the ttSortableColumn property.

- - - - - {{ col.header }} - - - - - - - - - {{ rowData[col.field] }} - - - - + + + + + + {{ col.header }} + + + + + + + + + {{ rowData[col.field] }} + + + + +
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class SortSingleColumnDoc implements OnInit { +export class SortSingleColumnDoc { files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ diff --git a/src/app/showcase/doc/treetable/templatedoc.ts b/src/app/showcase/doc/treetable/templatedoc.ts index 768dbbb022b..b9130123515 100644 --- a/src/app/showcase/doc/treetable/templatedoc.ts +++ b/src/app/showcase/doc/treetable/templatedoc.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TreeNode } from 'primeng/api'; import { Code } from '../../domain/code'; import { NodeService } from '../../service/nodeservice'; @@ -15,45 +15,48 @@ interface Column {

Custom content at caption, header, body and summary sections are supported via templating.

- -
File Viewer
- - - - {{ col.header }} - - - - - - - - {{ rowData[col.field] }} - - - - - - - - -
- -
-
-
+ + +
File Viewer
+ + + + {{ col.header }} + + + + + + + + {{ rowData[col.field] }} + + + + + + + + +
+ +
+
+
+
- ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class TemplateDoc implements OnInit { +export class TemplateDoc { files!: TreeNode[]; cols!: Column[]; constructor(private nodeService: NodeService) {} - ngOnInit() { + loadDemoData() { this.nodeService.getFilesystem().then((files) => (this.files = files)); this.cols = [ { field: 'name', header: 'Name' }, @@ -62,7 +65,6 @@ export class TemplateDoc implements OnInit { { field: '', header: '' } ]; } - code: Code = { basic: `
File Viewer
diff --git a/src/app/showcase/doc/treetable/treetabledoc.module.ts b/src/app/showcase/doc/treetable/treetabledoc.module.ts index 8d5161d50e4..444d1835514 100644 --- a/src/app/showcase/doc/treetable/treetabledoc.module.ts +++ b/src/app/showcase/doc/treetable/treetabledoc.module.ts @@ -43,9 +43,11 @@ import { AccessibilityDoc } from './accessibilitydoc'; import { PaginatorLocaleDoc } from './paginatorlocaledoc'; import { SizeDoc } from './sizedoc'; import { GridlinesDoc } from './gridlinesdoc'; +import { ControlledDoc } from './controlleddoc'; +import { DeferredDemo } from '../../demo/deferreddemo'; @NgModule({ - imports: [CommonModule, AppCodeModule, AppDocModule, TreeTableModule, ButtonModule, RouterModule, InputTextModule, SelectButtonModule, FormsModule, InputSwitchModule, ToastModule, MultiSelectModule, ContextMenuModule], + imports: [CommonModule, AppCodeModule, AppDocModule, TreeTableModule, ButtonModule, RouterModule, InputTextModule, SelectButtonModule, FormsModule, InputSwitchModule, ToastModule, MultiSelectModule, ContextMenuModule, DeferredDemo], exports: [AppDocModule], declarations: [ ImportDoc, @@ -78,7 +80,8 @@ import { GridlinesDoc } from './gridlinesdoc'; PaginatorLocaleDoc, ResizeScrollableDoc, SizeDoc, - GridlinesDoc + GridlinesDoc, + ControlledDoc ] }) export class TreeTableDocModule {} diff --git a/src/app/showcase/pages/treetable/treetabledemo.ts b/src/app/showcase/pages/treetable/treetabledemo.ts index e470005025d..90315121b83 100755 --- a/src/app/showcase/pages/treetable/treetabledemo.ts +++ b/src/app/showcase/pages/treetable/treetabledemo.ts @@ -30,6 +30,7 @@ import { PaginatorLocaleDoc } from '../../doc/treetable/paginatorlocaledoc'; import { ResizeScrollableDoc } from '../../doc/treetable/columnresizescrollabledoc'; import { SizeDoc } from '../../doc/treetable/sizedoc'; import { GridlinesDoc } from '../../doc/treetable/gridlinesdoc'; +import { ControlledDoc } from '../../doc/treetable/controlleddoc'; @Component({ templateUrl: './treetabledemo.html' @@ -51,6 +52,11 @@ export class TreeTableDemo { label: 'Dynamic Columns', component: DynamicColumnsDoc }, + { + id: 'controlled', + label: 'Controlled', + component: ControlledDoc + }, { id: 'template', label: 'Template',