Skip to main content

Timeline for Lightning client side sorting

Current License: CC BY-SA 3.0

13 events
when toggle format what by license comment
Sep 4, 2018 at 2:50 comment added sfdcfox @ArpitSethi get sortAsc, sortField, and list of records. set sortAsc to true if field changes, toggle sortAsc otherwise (true->false, false->true). call Array.prototype.sort using a function that returns 0 if the two elements are equal, -1 when "a" should appear before "b" in the list, and 1 otherwise. store the changed attributes.
Sep 3, 2018 at 23:55 comment added Arpit Sethi Can anyone please explain the code in "opportunityHelper.js", how it works. Just wanted to understand instead of copy paste.
May 10, 2018 at 23:51 comment added SamuelDev @sfdcfox, i've created a separate question here: salesforce.stackexchange.com/questions/217688/…
May 10, 2018 at 22:21 comment added sfdcfox @SamuelDev Yes, you should be able to do so, though I didn't only for simplicity. If you're having a problem with your code, might I suggest opening a new question and including your code there? It's pretty hard to address something like this in a comment.
May 10, 2018 at 22:15 comment added SamuelDev Hello @sfdcfox, your solution works. However, I was trying to create a sorting function and pass that function to the .sort method like this: records.sort(this.mySortingFunction) (the mySortingFunction and the records sorting are both in the helper). Is there a way to do this? Or is the inline sorting the only thing that works?
Oct 25, 2017 at 0:27 history edited sfdcfox CC BY-SA 3.0
added 162 characters in body
Jun 22, 2017 at 20:24 comment added JRiffe @sfdcfox Great gist! Helped me a lot in a sorting and pagination solution that I needed! Although the direct link doesn't work anymore. But you can still find it easy enough.
Nov 27, 2016 at 22:55 vote accept cartman
Nov 24, 2016 at 21:22 comment added sfdcfox @cartman I wrote a gist that demonstrates pagination + sorting client-side. Does this help you?
Nov 24, 2016 at 18:42 comment added sfdcfox @cartman aura:iteration doesn't support things like limit/offset, but you could load all of the records into a single variable, then call Array.slice to pull out some of those records into a separate list; you can then iterate over those. The event handlers for next, prev, first, last, etc would simply slice out a chunk of the main record array for display purposes. Sorting, of course, would occur on the master record list, as demonstrated here.
Nov 24, 2016 at 17:49 comment added cartman Thanks for the reply, I didn't frame my question correctly I use offset over multiple pages is there anyway that I could limit number of records on each page with in the JavaScript?
Nov 22, 2016 at 22:01 history edited sfdcfox CC BY-SA 3.0
added 2569 characters in body
Nov 22, 2016 at 21:41 history answered sfdcfox CC BY-SA 3.0