SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I am trying to create an a to z directory from a list of items which should be an easy task and it is really, however, I am trying to find the most efficient way of doing it.

So I was thinking use querystring as a filter value and then loop through, outputting the items where the first letter matches the letter that is specified in the querystring.

This works, yay! But i know it is inefficient, I shoup be querying the list for all items that have the first letter and then displaying them.

Anyone know a good way to do this, even pseudo code is fine, i am not expecting anyone to do this for me just pointing in the right direction would be good.

For clarification, I want to create this in code, no code solutions are no good here as there is other stuff going on too.

Thanks

share|improve this question

I am going to cover a few things as I don't know exactly what you're doing here.

  1. Create a calculated column to display the first letter of your field using formula - lets call this "FirstLetter"

    =LEFT([YourFieldName],1)

  2. Optionally, you can then use the Group By feature to show a collapsed/expanded list on [FirstLetter] - (see "The By Last Name View" here for an example)

  3. You can then filter on your First Letter using the normal List View filtering operation.

  4. Additionally you could add a filter provider web part (built in if using MOSS/2010 Server) or lots of 3rd part web parts about.

  5. Or you can make use of filtering via the query sting - e.g. you put on end of url

    ?FilterField1=FirstLetter&FilterValue1=X

    and this will apply the X filter.

So you can build up a a 'chooser' by adding something like the following HTML to a Content Editor Web Part (CEWP) or source in wiki.

<a href="/yoursite/yourpage.aspx?FilterField1=FirstLetter&FilterValue1=A">A</a> |
<a href="/yoursite/yourpage.aspx?FilterField1=FirstLetter&FilterValue1=B">B</a> |
<a href="/yoursite/yourpage.aspx?FilterField1=FirstLetter&FilterValue1=B">C</a> |

and so on

share|improve this answer

I would simply create a calculated column that displays the first letter of the Item Title and then use that in my views to display it for users. The group by view shows and totals how many "A>Z" items are in the list as well.

Set up column:

enter image description here

then you have a view that looks like this

enter image description here

and it can be grouped like this

enter image description here

share|improve this answer

http://kwizcom.blogspot.com/2007/06/creating-a-z-filter-for-list.html http://sharepointkb.wordpress.com/2009/02/23/creating-a-z-expandingcollapsing-lists/ http://sympmarc.com/2009/06/19/alpha-selection-of-list-items/

share|improve this answer

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

1  
Please add some important part of your answer here because once the link broken it will be of no use to the community members. You can include some essential part here and give the reference as your link – Aakash Morya Jul 16 at 3:41
1  
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Waqas Sarwar MCSE Jul 16 at 3:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.