primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Filtering datatable columns that use templates does not filter against template value

Open fis-dan-wnuk opened this issue 10 years ago • 1 comments

I have a datatable setup like this:

    <p-dataTable #table [value]="entries" [sortMode]="multiple" [rows]="10" [paginator]="true" [responsive]="true" [selectionMode]="getSelectionMode()"
                 (selection)="getSelection()" [contextMenu]="cm" (onContextMenuSelect)="onContextSelect($event)" (onRowClick)="onClick($event)">
        <p-column *ngIf="select" styleClass="checkbox-column">
            <template let-entry="rowData">
                <input type="checkbox" (click)="onCheckboxClick($event, entry)" [checked]="isEntrySelected(entry)" />
            </template>
        </p-column>
        <p-column *ngFor="let column of columns" [field]="column.value" [header]="column.label" [sortable]="true" [filter]="true">
        </p-column>
    </p-dataTable>

The filtering works fine in this above example.

I would like to run the values through a formatting function first (which can transform a "user status" string from "A" to "Active", for example), so I switched this over to a template:

        <p-column *ngFor="let column of columns" [field]="column.value" [header]="column.label" [sortable]="true" [filter]="true">
            <template let-entry="rowData">
                {{getColumnValue(entry, column)}}
            </template>
        </p-column>

This displays the values as expected, but filtering on the columns will filter against the model, and not the new display values. It would be nice if the filtering could take into account the display values as well.

fis-dan-wnuk avatar May 25 '16 14:05 fis-dan-wnuk

There is a limitation here, we can't know what you have inside the template. Feel free to suggest adding a new property like filterField to filter against in a new issue.

cagataycivici avatar Mar 09 '17 08:03 cagataycivici