Need to reset TurboTable when changing tabs in tab view

UI Components for Angular
Post Reply
fpsadmin
Posts: 1
Joined: 12 Jul 2018, 11:12

09 Oct 2018, 17:35

I currently have a Tab View wrapping a Turbo Table. The Turbo Table has a row expand as well as filters. Currently when switching tabs the expanded row remains expanded. But the content in the expanded section of the row needs to be loaded dynamically. Id the row is already expanded then the row shows incorrect data when switching tabs. This is why I need to reset the table somehow.

Code: Select all

<p-tabView orientation="left" [activeIndex]="index">
            <p-tabPanel [header]="property.name" *ngFor="let property of selectedProperties; let i = index" [selected]="i == 0">
                <ng-template pTemplate="content">
                        <p-table #dt [columns]="cols" [value]="property?.pitches" 
                                 rowExpandMode="single"
                                 (onRowExpand)="loadComments($event)" (onRowCollapse)="hideComments($event)" > <!-- loadComments makes a service call. -->
                            <ng-template pTemplate="header" let-columns>
                                <tr>
                                    <th style="width: 3em"></th>
                                    <th *ngFor="let col of columns" [pSortableColumn]="col.sort">
                                        {{col.header}}
                                        <p-sortIcon [field]="col.sort"></p-sortIcon>
                                    </th>
                                </tr>
                            </ng-template>
                            <ng-template pTemplate="body" let-rowData let-columns="columns" let-expanded="expanded" >
                                <tr [pSelectableRow]="rowData">
                                    <td>
                                        <a href="#" [pRowToggler]="rowData">
                                            <i [ngClass]="expanded ? 'pi pi-chevron-down' : 'pi pi-chevron-right'"></i>
                                        </a>
                                    </td>
                                    <td *ngFor="let col of columns">
                                        {{rowData[col.field] ? rowData[col.field][col.nested] : ''}}
                                    </td>
                                </tr>
                            </ng-template>
                            <ng-template pTemplate="rowexpansion" let-rowData let-columns="columns">
                                <tr>
                                    <td [attr.colspan]="columns.length + 1">
                                    </td>
                                </tr>
                            </ng-template>
                        </p-table>
                    </div>
                </div>
                </ng-template>
            </p-tabPanel>
        </p-tabView>
Ideally I want to call table.reset onChange of the tab view, but can't get a handle on the p-table in the ts file.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 25 guests