PRIMENG: How to get detailed data onRowExpand event?

UI Components for Angular
Post Reply
mohsenpourian
Posts: 2
Joined: 12 Nov 2017, 17:52

12 Nov 2017, 17:56

This is my prime-ng datatable sample code:

Code: Select all

<p-dataTable [value]="docs" expandableRows="true" (onRowExpand)="onRowExpand($event)"> 
   <p-column field="doc_Id" header="id"></p-column>
   <p-column field="doc_Title" header="title"></p-column>
   <ng-template let-rowIndex="rowIndex" pTemplate="rowexpansion" >
         {{rowIndex}}
         <p-treeTable selectionMode="single" [value]="getDetails(rowIndex)">       
              <p-column field="h1"></p-column>
              <p-column field="h2"></p-column>
          </p-treeTable>
   </ng-template> </p-dataTable>
in this case when user expand any doc row, we use getDetails(rowIndex) to get specific detailed data from service:

Code: Select all

 getDetails(rowIndex) {
     console.log("getDetails-rowIndex:" + rowIndex);
     // ....from service
     return detaildata;  }
But there are two problems:

on every click on expand icon , getDetails(rowIndex) repeats more than 10 times...
if user expanded another table rows before, then multiple row rowIndex recieved.
console log samples

Image

as summary we need only recently last rowindex that expanded, with one time event call.

any solution?

mohsenpourian
Posts: 2
Joined: 12 Nov 2017, 17:52

21 Nov 2017, 11:00

any solution???

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

21 Nov 2017, 13:11

Okay, Can you report the issue in github with plunker example. It shouldn't be called these many times.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests