primeng icon indicating copy to clipboard operation
primeng copied to clipboard

sortFunction in Column doesn't work

Open loliparra80 opened this issue 10 years ago • 4 comments

I have defined in my html the next column inside dataTable: <p-column field="auxRequestDate" header="Test1" sortable="true" (sortFunction)="orderDate($event)">

Where the sortfunction is simple like orderDate(event) { console.log(event); }

But never enter in the function, because I have any message in console when debugging, so what I am doing wrong?

Thankyou

loliparra80 avatar Aug 10 '16 07:08 loliparra80

I am going to answer myself, my problem was that in the field "sortable" we need to write "custom", anyway doesn't work the sortFunction

loliparra80 avatar Aug 11 '16 07:08 loliparra80

I have the the same issue on the latest version 1.0.0-beta.16

mavezeau avatar Sep 19 '16 14:09 mavezeau

My solution was: HTML (code): <p-column field="auxRequestDate" header="datetime_request" sortable="custom" (sortFunction)="orderDate($event)" TS (code): orderDate(event) { if (event.field == "auxRequestDate") { if (event.order == 1) this.dataGrid.sort((a, b) => { return (a["requestDate"]) - (b["requestDate"]); }); else this.dataGrid.sort((a, b) => { return (b["requestDate"]) - (a["requestDate"]); }); } }

loliparra80 avatar Sep 21 '16 10:09 loliparra80

I can't replicate with PrimeNG 4.0.1, please drop a comment if issue still persists.

cagataycivici avatar May 29 '17 13:05 cagataycivici