当数据与惰性

时间:2017-01-05 06:32:07

标签: angular primeng

当我使用基本方式将数据绑定到p-dataTable时,列的p-dropdown过滤器工作正常,但是当我使用[lazy] =" true"绑定p-dataTable时(onLazyLoad)=" loadData($事件)"然后下拉列过滤器无效。

工作代码:

    <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>

不工作代码:

    <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>

工作代码与不工作代码之间的差异为

[懒] =&#34;真&#34; (onLazyLoad)=&#34; loadData($事件)&#34;在第一行的p-dataTable绑定中。

0 个答案:

没有答案