简体   繁体   中英

Primeng p-table - Show data instead of id

Is there a way in p-table to show the value instead of Id?

Eg: I get the data from server as below

[
   {row_id: 1, customer_id: 25, status: 'NEW'},
   {row_id: 1, customer_id: 26, status: 'NEW'},
]

I want to replace the customer id with customer name in the p-table with shows above data. I have the mapping of customer id to customer name as below

[
   {rowid: 25, name: 'Vinod'},
   {row_id: 26, name: 'Ram'}
]

Edit I achieved this using Angular Pipe. But is there a p-table way of doing it?

You could keep you mapping array as below instead.

this.mapping = {
   25: {name: 'Vinod', age: 25},
   26: {name: 'Ram'}
}

and in your html as below.

<td>mapping[rowData['customer_id']].name</td>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM