'Why PrimeNG p-table Reorder doesn't work on imported module
When I use this code from documentation it works on root module, but I want to do the same thing in lazy loaded module? When I try reorder table on lazy loaded module it freezes. I've looked on the import and everything is ok so if anybody had the same issue please help :).
HTML
<p-table [value]="products" [columns]="cols" [reorderableColumns]="true" responsiveLayout="scroll">
<ng-template pTemplate="header" let-columns>
<tr>
<th style="width:3rem"></th>
<th *ngFor="let col of columns" pReorderableColumn>
{{col.header}}
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData let-columns="columns" let-index="rowIndex">
<tr [pReorderableRow]="index">
<td>
<span class="pi pi-bars" pReorderableRowHandle></span>
</td>
<td *ngFor="let col of columns">
{{rowData[col.field]}}
</td>
</tr>
</ng-template>
</p-table>
TS:
import { Component, OnInit } from '@angular/core';
import { Product } from '../../domain/product';
import { ProductService } from '../../service/productservice';
@Component({
templateUrl: './tablereorderdemo.html'
})
export class TableReorderDemo implements OnInit {
products: Product[];
cols: any[];
constructor(private productService: ProductService) { }
ngOnInit() {
this.productService.getProductsSmall().then(data => this.products = data);
this.cols = [
{ field: 'code', header: 'Code' },
{ field: 'name', header: 'Name' },
{ field: 'category', header: 'Category' },
{ field: 'quantity', header: 'Quantity' }
];
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
