p-dropdown filter is not working in p-dataTable when data is binded with lazy

1.8k views Asked by At

When I bind data to p-dataTable using basic way the p-dropdown filter for column is working fine but when I bind p-dataTable using [lazy]="true" (onLazyLoad)="loadData($event)" then the dropdown column filter is not working.

Working Code:

    <p-dataTable #dt id="myDataTable" [value]="data" selectionMode="single" (onRowSelect)="onRowSelect($event)" [paginator]="true"
                     rows="10" [responsive]="true" [totalRecords]="totalRecords">
            <p-column field="Name" header="Name" [sortable]="true" [filter]="true" filterMatchMode="contains" [style]="{'width':'20%'}"></p-column>
            <p-column field="Type" header="Type" [sortable]="true" [filter]="true" filterMatchMode="equals" [style]="{'width':'20%','overflow':'visible'}">
                <template pTemplate="filter" let-col>
                    <p-dropdown [options]="typesFilter" [style]="{'width':'100%'}" (onChange)="dt.filter($event.value,col.field,col.filterMatchMode)" styleClass="ui-column-filter"></p-dropdown>
                </template>
            </p-column>
        </p-dataTable>

Not Working Code:

    <p-dataTable #dt id="myDataTable" [value]="data" selectionMode="single" (onRowSelect)="onRowSelect($event)" [lazy]="true" (onLazyLoad)="loadData($event)" [paginator]="true"
                     rows="10" [responsive]="true" [totalRecords]="totalRecords">
            <p-column field="Name" header="Name" [sortable]="true" [filter]="true" filterMatchMode="contains" [style]="{'width':'20%'}"></p-column>
            <p-column field="Type" header="Type" [sortable]="true" [filter]="true" filterMatchMode="equals" [style]="{'width':'20%','overflow':'visible'}">
                <template pTemplate="filter" let-col>
                    <p-dropdown [options]="typesFilter" [style]="{'width':'100%'}" (onChange)="dt.filter($event.value,col.field,col.filterMatchMode)" styleClass="ui-column-filter"></p-dropdown>
                </template>
            </p-column>
        </p-dataTable>

Difference between working and not working code is as

[lazy]="true" (onLazyLoad)="loadData($event)" in p-dataTable bind at first row.

0

There are 0 answers