Thread: Sort MultiSelect on page Init

+ Reply to Thread
  1. #1

    Sort MultiSelect on page Init

    I have a Multiselect box that I am trying to get to sort alphabetically. I populate it on Page_init with text and values from a search string. Code is here:
    For Each Member As Object In CType(Members, IEnumerable)  ' loop through members
    
                Dim CurrentMember As New DirectoryEntry(Member) ' Get directoryentry for user
    
    
                UList.Add(CurrentMember.Name.Remove(0, 3))
                EList.Add(CurrentMember.Properties("mail").Value.ToString)
    
                Dim c As New Ext.Net.ListItem.Config
                c.Text = CurrentMember.Name.Remove(0, 3)
                c.Value = CurrentMember.Properties("mail").Value.ToString
                MultiSelect1.Items.Add(New Ext.Net.ListItem(c))
    
    
            Next
    I have this code in my aspx page
    <ext:MultiSelect ID="MultiSelect1" runat="server" SubmitText = "true"  Height="500" Width="200" Direction ="ASC" SortField = "text"></ext:MultiSelect>
    But it does not seem to work at all, is there something I am missing? Any help is greatly appreciated.

  2. #2
    Ext.NET - Dev Team
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    5,268
    Hi,

    Could you sort the data ASC before adding to the MultiSelect?
    Geoffrey McGill
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext JS API Docs | Twitter

  3. #3
    I could but I would have to add it to another array/list first and I am trying to avoid the extra overhead. I would like to keep it coming directly from the search results.

  4. #4
    Ext.NET - Dev Team
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    8,450
    Hi,

    You can
    - use Store control instead inner Items and set SortInfo for default sorting
    - or please use the following listener for the MultuSelect
    <AfterRender Handler="this.store.sort('text');"/>
    or
    <AfterRender Handler="this.store.sort('value');"/>
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext JS API Docs | Twitter

  5. #5
    That was it, thanks a lot, much appreciated. How do I mark this as solved?

+ Reply to Thread

Tags for this Thread