This is a migrated thread and some comments may be shown as answers.

GroupBy Alphabet

3 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phill Hodgkinson
Top achievements
Rank 1
Phill Hodgkinson asked on 06 Jul 2009, 06:50 PM
Hi There,

I'm wondering if anyone has attempted this before and can possibly point me in the right direction. I have a rather long list of company names and would like to be able to group them alphabetically, with the letter of the alphabet being the title for the group. So it would look something like:
A
ABC Company
Apple Company
B
BCD Company
Banana Company

Any ideas? I assume this would be a Custom GroupByExpression but I have very limited experience with the Telerik Grid (this is for a SItefinity project that uses the grid). Any help would be greatly appreciated!

Cheers,
Phill

3 Answers, 1 is accepted

Sort by
0
Phill Hodgkinson
Top achievements
Rank 1
answered on 08 Jul 2009, 02:13 PM
Hi there,
So I've made a bit of progress by adding Select *, left(Name,1) AS GroupLetter from Table to my SQL statement and can use GroupLetter as my GroupByField. The trouble I'm having is that I don't want to have any text with the letter other than the letter itself. All Grouping examples have something like "Total: #"  or "Country: Canada"  I don't want to have any text and/or character before the Letter. Is there a way to do this? If I don't define the text it displays "GroupLetter: A" as a default instead.

Thanks again for any help.
Cheers,
Phill
0
Yavor
Telerik team
answered on 09 Jul 2009, 07:10 AM
Hello Phill,

Indeed, having a separate field from the datasource, for the first letters, and then using this field to group on, is the most straightforward approach in this case. This ensures that the functionality is handled automatically, at the database level, and avoid complex custom coding.
Further, you can alter the grouping text, as shown in the following article:

http://www.telerik.com/help/aspnet-ajax/grdcustomizegridgroupheaderitem.html

I hope this information helps.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Phill Hodgkinson
Top achievements
Rank 1
answered on 09 Jul 2009, 02:04 PM
Exactly the link I was looking for! My apologies for not being able to find it on my own!

Many thanks!
Phill
Tags
Grid
Asked by
Phill Hodgkinson
Top achievements
Rank 1
Answers by
Phill Hodgkinson
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or