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 sort in table not working. #15550

Closed
mahesh-mathew opened this issue May 13, 2024 · 4 comments · Fixed by #15996 · 4 remaining pull requests
Closed

Custom sort in table not working. #15550

mahesh-mathew opened this issue May 13, 2024 · 4 comments · Fixed by #15996 · 4 remaining pull requests
Assignees
Labels
LTS-FIXED-15.4.23 LTS-FIXED-16.9.13 LTS-PORTABLE Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@mahesh-mathew
Copy link

Describe the bug

Custom sort is not working expected. (sortFunction)="customSort($event)" is not getting triggered.Using the vesrion "primeng": "^17.16.0".

<p-table
#dt
[columns]="cols"
[value]="values"
(sortFunction)="customSort($event)" [customSort]="true"
[tableStyle]="{ 'min-width': '50rem' }"
[paginator]="true"
[rows]="10"
[scrollable]="true"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries"
(onPage)="onPaginate($event)"
[showCurrentPageReport]="true"
[totalRecords]="totalRecords"
[lazy]="true"
[rowsPerPageOptions]="[5, 10, 20]"
[selectionMode]="'multiple'"
[(selection)]="selectedRows"

In ts
import { ConfirmationService, SortEvent } from 'primeng/api';

customSort(event : SortEvent){
console.log(event);

}

tried as per the latest documentation.But customSort Method is not triggered while applying the sort.

Environment

local environment

Reproducer

No response

Angular version

17.00

PrimeNG version

17.16.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.11.0

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@mahesh-mathew mahesh-mathew added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 13, 2024
@Sinan997
Copy link
Contributor

Sinan997 commented May 17, 2024

Hi, https://primeng.org/table#removable-sort it works.

Could you share stackblitz link?

@FedericoStroppiana
Copy link

sortFunction is not triggered when lazy is true

@AIO1
Copy link

AIO1 commented Jun 17, 2024

sortFunction is not triggered when lazy is true

@Sinan997 I can confirm this is happening. Custom sort is not triggered if lazy load is being used.

@mehmetcetin01140 mehmetcetin01140 self-assigned this Jul 10, 2024
@mehmetcetin01140 mehmetcetin01140 added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jul 10, 2024
@mehmetcetin01140 mehmetcetin01140 added this to the 17.18.4 milestone Jul 10, 2024
cetincakiroglu added a commit that referenced this issue Jul 11, 2024
Fixed #15550 - Table | Custom sort in table not working
@MikeMatusz
Copy link
Contributor

MikeMatusz commented Sep 11, 2024

@mehmetcetin01140 @cetincakiroglu
Why the sudden reversal on this? There have been numerous issues and discussions in the past, and if you have [lazy]="true", then sorting and filtering should be done on the server or in the onLazyLoad function. This makes sense, as the client doesn't have all the data. If the sort changes, you need to consider records not loaded into data yet.

This was a breaking change, and doesn't make sense to me. As we have a shared wrapper where lazy is conditional, this caused issues our code and we have to short-circuit out of our sort function now, when previously it was never called. Why would we want to sort client-side if we don't have all the records that need to be sorted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment