Alphabetical sorting

  • 1
  • Question
  • Updated 4 years ago
  • Answered
HI , I want to have alphabetical sorting on my page to extract the records by the start of its letter like we have in standard salesforce page like a, b c, d......plz suggest
Photo of Rimali Gurav

Rimali Gurav

  • 272 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
Hi,

You can make a condition in the model like Name starts with '' Filterable.

And make buttons or a filter in a table to set and apply the condition with each letter
Photo of Sayan Choudhury

Sayan Choudhury

  • 172 Points 100 badge 2x thumb
Can you please explain the second part of your answer. I mean would be helpful if you provide an example.

Thanks in advance
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
You can do a lot of things, this are examples (quick thought):
1.- buttons: 
Create buttons for each letter with a redirect to your page adding the "nameofthefilter=a", "nameofthefilter=b" ....

for example: (assuming the  page is called 'ListPage' filter is called 'namestartswith')  the url will be something like '/apex/ui?page=ListPage&namestartswith=a'

this will refresh the page and set and activate the condition 'namestartswith' with the letter a.

2.- template.
you can do the same in a template. Cons: a lot of manual html code. Pros: easily to apply styles. the template will be something like '<a href="/apex/ui?page=ListPage&namestartswith=a">A</a><a href="/apex/ui?page=ListPage&namestartswith=b">B</a> ...'

3.- filter in the table.
Create a filter in a table with all the options and set and activate the condition.
Pros: refresh only the table, not the page. Cons: it's a table filter it will be shown as a select box in the table (not like an index)

4.- filter in a table with an aggregate model.

- Create a formula field in your object to get the initial.
- Use this field in a aggregate model of your object to get all the initials (group by this field)
- create a filter in the table to set and activate the condiiton.
- configure the filter to get all the options from the rows of the aggregate model.

Pros: same as point 3 and you don't have to write all the letters, and if there is no record with the initial M, the M letter will not be shown.

Cons: same as point 3 and if there is no record with the initial M, the M letter will not be shown. (maybe you don't desire this behaviour)

5;- create a component (javascript involved)
Photo of Rimali Gurav

Rimali Gurav

  • 272 Points 250 badge 2x thumb
Thanks Pablo for your reply..will try it out and will let you know.
Photo of Sayan Choudhury

Sayan Choudhury

  • 172 Points 100 badge 2x thumb
Thanks Pablo. :)
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Yes!  Thanks Pablo.  You've gone far above and beyond what I was thinking.  I was going to stop at idea #3...