How to get data from multiple subobject using p-columnFilter PrimeNG Table?

UI Components for Angular
Post Reply
Shannonmaus
Posts: 8
Joined: 06 Mar 2023, 11:35

16 Mar 2023, 06:54

I want to column filter multiple collection of data using PrimeNG table. The JSON response example below enter image description here.
And so on. On the body of the p-table, I listed the subobject type of each object using *ngFor for each one on the samecolumn:enter image description here As "the desired subject names filter" say above, I want to get filter the property of the mappings "object types" subobjects from each object. Any help is appreciated. HEB Partner

Hezamatthew
Posts: 3
Joined: 09 Nov 2022, 07:53

20 Mar 2023, 13:30

Shannonmaus wrote:
16 Mar 2023, 06:54
I want to column filter multiple collection of data using PrimeNG table. The JSON response example below enter image description here.
And so on. On the body of the p-table, I listed the subobject type of each object using *ngFor for each one on the samecolumn:enter image description here As "the desired subject names filter" say above, I want to get filter the property of the mappings "object types" subobjects from each object. Any help is appreciated.
To filter the "object types" subobjects from each object in the JSON response using PrimeNG table, you can use the filter property of the p-column component in the p-table component.

Here is an example of how you can filter the "object types" subobjects from each object:

Code: Select all

<p-table [value]="jsonData">
  <ng-container *ngFor="let subObject of jsonData[0].mappings">
    <p-column field="mappings" header="Object Types" [filter]="true" filterField="objectType">
      {{ subObject.objectType }}
    </p-column>
  </ng-container>
</p-table>
In this example, I am using ngFor to loop through each subobject in the mappings array of the first object in the jsonData array. Inside the loop, I am using the p-column component to display the objectType property of each subobject.

The [filter]="true" attribute enables filtering for the column, and filterField="objectType" specifies that we want to filter by the objectType property. This means that the user can type in a search term in the filter box, and the table will filter the rows based on whether the objectType property of the subobject matches the search term.

I hope this helps you with your filtering needs! Let me know if you have any further questions. TellTims

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests