- Home
- Forum
- ASP.NET MVC - EJ 2
- Custom Sorting - Ascending and descending
Custom Sorting - Ascending and descending
Hello Syncfustion Team!
I implemented a custom sort comparer for a date column with dd/MM/yyyy format, and is working perfectly for descending order, but how can I implement ascending order?
function sortDateComparer(a, b) { a = new Date(a); b = new Date(b); return a > b ? -1 : a < b ? 1 : 0; }
Thanks in advance.
SIGN IN To post a reply.
3 Replies
PS
Pavithra Subramaniyam
Syncfusion Team
October 18, 2019 10:13 AM UTC
Hi Matias,
Thanks for contacting Syncfusion support.
We have validated the provided code example and We suggest you to use the below way to achieve your requirement.
|
function sortDateComparer(a, b) {
a = new Date(a);
b = new Date(b);
return a > b ? 1 : a < b ? -1 : 0;
}
|
Help documentation: https://ej2.syncfusion.com/documentation/api/grid/column/#sortcomparer
Note: If a is less than b return -1 if a greater than b then return 1
Regards,
Pavithra S.
MP
Matias Puzanowski
October 18, 2019 12:43 PM UTC
Thanks a lot for replying and also for providing documentation, but I think that we misunderstood. Sort is working, but only in one way.
Descending (ordered perfectly):
Ascending (ordered just as descending):
So how can I do to sort in both ways?
Thanks in advance.
PS
Pavithra Subramaniyam
Syncfusion Team
October 21, 2019 12:20 PM UTC
Hi Matias,
Thanks for your update.
We have validated the provided information and checked with our end but we could not face the reported problem, both ascending and descending working fine at our sample. Please refer the below sample for more information.
[Ascending result]
|
|
[Descending]
|
|
Could you please share more details or below information that will be more helpful for us to validate further at our end.
- Do you want to perform multiple sorting in Grid?
- Share the full code example and package version details.
- Share the video demo of your issue
- If possible share the sample or reproduce the reported problem at our end
Regards,
Pavithra S.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
MP Matias Puzanowski
- Oct 17, 2019 07:19 PM UTC
- Oct 21, 2019 12:20 PM UTC