Sunday, 5 May 2019

How to search inside the array in primeNg p-table.?

I am having the data points like an array. So I am trying to search the value inside the array but it is not working in primeng

In the component file I am having the below part of code,

tableHeader = [
    { field: 'name', header: 'Name' },
    { field: 'skills', header: 'Skills' },
];

data = [
    {
        name:"User1",
        skills:["JS","Java","Angular"]
    },{
        name:"TestUser",
        skills:["HTML","Css"]
    },{
        name:"Root",
        skills:["HTML","Css","Angular","Python","Perl"]
    }
];

And the html is

<p-table #dt [value]="data">
    <ng-template pTemplate="header">
    <tr>
            <th>Name</th>
            <th>Skills</th>
    </tr>
    <tr>
        <th>
            <input pInputText type="text" (input)="dt.filter($event.target.value, 'name', 'contains')">
        </th>
        <th>
            <input pInputText type="text" (input)="dt.filter($event.target.value, 'skills', 'contains')">
        </th>
    </tr>
    </ng-template>
    <ng-template pTemplate="body" let-rowData>
        <tr>
            <td></td>
            <td>
                <span *ngFor="let skill of rowData.skills;">
                
                </span>
            </td>
        </tr>
    </ng-template>
<p-table> 

I am able to search the Name field but I am not able to search the Skills field. because it contains the array value.



from How to search inside the array in primeNg p-table.?

No comments:

Post a Comment