Sort by Value

4 posts, 1 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 17 Aug 2010 Link to this post

    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
  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 20 Aug 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 20 Aug 2010 Link to this post

    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
  5. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 23 Aug 2010 Link to this post

    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
Back to Top