Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

3 Answers 3

You may also look into the following article http://nazishqasim.wordpress.com/2012/11/26/using-data-view-web-part-to-achieve-a-z-index-listings/

share|improve this answer
    
While this may theoretically answer the question, we prefer inclusion of the essential parts of the answer here, and to provide the link for reference, especially when it is a link to your own blog. See answer for general guidelines. –  SPDoctor Mar 4 '13 at 21:30

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

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

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.