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

Sort by Value

3 Answers 56 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Stuart Hemming
Top achievements
Rank 2
Stuart Hemming asked on 17 Aug 2010, 04:45 PM
Rather than sorting my listboxes by the Text property of the ListBoxItems, I want to use the Value property.

I understand that I'm going to have to do that server-side and I have no problem with that it's just that the following seems a lot of work...
public partial class HierarchyMaintenance : System.Web.UI.Page
{
    protected void ListBox_Transferred(object sender, RadListBoxTransferredEventArgs e)
    {
        e.DestinationListBox.Items.Sort(new ListBoxValueComparer());
    }
 
    public class ListBoxValueComparer : System.Collections.IComparer
    {
        int System.Collections.IComparer.Compare(Object x, Object y)
        {
            string xValue = (x as RadListBoxItem).Value;
            string yValue = (y as RadListBoxItem).Value;
            return Comparer.DefaultInvariant.Compare(xValue, yValue);
        }
    }
}

And if I want to sort by an attribute I would have to create a comparer for each one.

It would be nice to be just able to write something like ...
e.DestinationListBox.Items = 
e.DestinationListBox.Items.OrderBy(i=>i.Attributes[
"MyAttribute"]);

Or have I missed something?

-- 
Stuart

3 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 20 Aug 2010, 09:26 AM
Hi Stuart,

Yes, this would be a nice feature to add for RadListBox. We will consider implementing it.


Greetings,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Stuart Hemming
Top achievements
Rank 2
answered on 20 Aug 2010, 09:29 AM
Peter,

If it get's added to PITS could you post a link here and I'll try drumming up a bit of support for it.

-- 
Stuart
0
Simon
Telerik team
answered on 23 Aug 2010, 10:28 AM
Hello Stuart Hemming,

You can track the status of the issue here.

All the best,
Simon
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ListBox
Asked by
Stuart Hemming
Top achievements
Rank 2
Answers by
Peter
Telerik team
Stuart Hemming
Top achievements
Rank 2
Simon
Telerik team
Share this question
or