admin管理员组文章数量:1384752
I am trying to implement the multiselect
in primeng table, Following I have tried
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './appponent.html',
styleUrls: [ './appponent.css' ]
})
export class AppComponent {
tableHeader= [
{ 'field': 'type', 'header': 'Type' },
{ 'field': 'value', 'header': 'Value' },
];
tableValue = [
{'type':'A1','value':'row1'},
{'type':'A1','value':'row2'},
{'type':'A2','value':'row3'},
{'type':'A2','value':'row4'},
{'type':'A1','value':'row5'},
];
statusOptions = [
{ 'label': 'A1', 'value': 'A1' },
{ 'label': 'A2', 'value': 'A2' }
];
}
and html file is
<p-table [columns]="tableHeader" [value]="tableValue" [sortOrder]="1"
[responsive]="true" rowHover="true" [rowsPerPageOptions]="[5,10,25]" alwaysShowPaginator="false" [rows]="10"
sortMode="multiple" #tdv>
<ng-template pTemplate="header">
<tr>
<th *ngFor="let col of tableHeader" [pSortableColumn]="col.field">
<span>{{col.header}}</span>
</th>
</tr>
<tr>
<th *ngFor="let col of tableHeader" [pSortableColumn]="col.field">
<p-multiSelect [options]="statusOptions" *ngIf='col.field =="type"' (onChange)="tdv.filter($event.value,col.field,'equals')"></p-multiSelect>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-row>
<tr>
<td>{{row.type}}</td>
<td>{{row.value}}</td>
</ng-template>
</p-table>
I am trying to filter the value with A1
and A2
. But If I select the single value it is working but if I select the multiple value it is not working. I don't know how to fix this issue..
I am trying to implement the multiselect
in primeng table, Following I have tried
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.ponent.html',
styleUrls: [ './app.ponent.css' ]
})
export class AppComponent {
tableHeader= [
{ 'field': 'type', 'header': 'Type' },
{ 'field': 'value', 'header': 'Value' },
];
tableValue = [
{'type':'A1','value':'row1'},
{'type':'A1','value':'row2'},
{'type':'A2','value':'row3'},
{'type':'A2','value':'row4'},
{'type':'A1','value':'row5'},
];
statusOptions = [
{ 'label': 'A1', 'value': 'A1' },
{ 'label': 'A2', 'value': 'A2' }
];
}
and html file is
<p-table [columns]="tableHeader" [value]="tableValue" [sortOrder]="1"
[responsive]="true" rowHover="true" [rowsPerPageOptions]="[5,10,25]" alwaysShowPaginator="false" [rows]="10"
sortMode="multiple" #tdv>
<ng-template pTemplate="header">
<tr>
<th *ngFor="let col of tableHeader" [pSortableColumn]="col.field">
<span>{{col.header}}</span>
</th>
</tr>
<tr>
<th *ngFor="let col of tableHeader" [pSortableColumn]="col.field">
<p-multiSelect [options]="statusOptions" *ngIf='col.field =="type"' (onChange)="tdv.filter($event.value,col.field,'equals')"></p-multiSelect>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-row>
<tr>
<td>{{row.type}}</td>
<td>{{row.value}}</td>
</ng-template>
</p-table>
I am trying to filter the value with A1
and A2
. But If I select the single value it is working but if I select the multiple value it is not working. I don't know how to fix this issue..
1 Answer
Reset to default 3The mutlisect
value when selecting A1 and A2 is "A1,A2"
so you need to use in
instead of equals
:
<p-multiSelect [options]="statusOptions" *ngIf='col.field =="type"' (onChange)="tdv.filter($event.value,col.field,'in')"></p-multiSelect>
本文标签: javascriptHow to use MultiSelect filter in PrimeNG tableStack Overflow
版权声明:本文标题:javascript - How to use Multi-Select filter in PrimeNG table.? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744477780a2607979.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论