Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom sortFunction for TurboTable #4926

Closed
cagataycivici opened this issue Jan 23, 2018 · 2 comments
Closed

Custom sortFunction for TurboTable #4926

cagataycivici opened this issue Jan 23, 2018 · 2 comments
Assignees
Labels
Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@cagataycivici
Copy link
Member

Define a callback called sortFunction, that receives the sort information and implements sorting instead of the built-in sorting.

@cagataycivici cagataycivici self-assigned this Jan 23, 2018
@cagataycivici cagataycivici added the Type: New Feature Issue contains a new feature or new component request label Jan 23, 2018
@cagataycivici cagataycivici added this to the 5.2.0-RC2 milestone Jan 23, 2018
@deepesh007
Copy link

deepesh007 commented Jan 31, 2019

You can use (sortFunction)="customSort($event)" for custom sorting.
callback function returns following information in event object:

//event.data = Data to sort
//event.mode = 'single' or 'multiple' sort mode
//event.field = Sort field in single sort
//event.order = Sort order in single sort
//event.multiSortMeta = SortMeta array in multiple sort

Example:

<p-table` [columns]="cols" [value]="cars" (sortFunction)="customSort($event)" [customSort]="true">
    <ng-template pTemplate="header" let-columns>
        <tr>
            <th *ngFor="let col of columns" [pSortableColumn]="col.field">
                {{col.header}}
                <p-sortIcon [field]="col.field"></p-sortIcon>
            </th>
        </tr>
    </ng-template>
    <ng-template pTemplate="body" let-rowData let-columns="columns">
        <tr>
            <td *ngFor="let col of columns">
                {{rowData[col.field]}}
            </td>
        </tr>
    </ng-template>
</p-table>

@praveenjarugu
Copy link

custom

It doesnt work with (sortFunction)="columnSort($event).
It is going infinite loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

No branches or pull requests

3 participants