Dynamically alphabetical order tabs of a radtabstrip

3 posts, 1 answers
  1. Borralis
    Borralis avatar
    5 posts
    Member since:
    Dec 2011

    Posted 15 Mar 2012 Link to this post

    Hi,

    Is there a way to sort tabs alphabetically in a radtabstrip?

    Thanks
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Mar 2012 Link to this post

    Hello,

    I suppose you want to arrange the tabs based on the alphabetical order of tab Text, if so please try the following code.
    ASPX:
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server">
     <Tabs>
      <telerik:RadTab Text="zebra">
       <Tabs>
        <telerik:RadTab Text="diary">
        </telerik:RadTab>
        <telerik:RadTab Text="ants">
        </telerik:RadTab>
       </Tabs>
      </telerik:RadTab>
      <telerik:RadTab Text="water">
       <Tabs>
        <telerik:RadTab Text="tea">
        </telerik:RadTab>
        <telerik:RadTab Text="coffee">
        </telerik:RadTab>
       </Tabs>
      </telerik:RadTab>
     </Tabs>
    </telerik:RadTabStrip>
    C#:
    protected void Page_Load(object sender, EventArgs e)
     {
      Sort(RadTabStrip1.Tabs);
      foreach (RadTab item in RadTabStrip1.GetAllTabs())
       {
        if (item.Tabs.Count> 0)
         {
          Sort(item.Tabs);
         }
       }
     }
    protected void Sort(RadTabCollection items)
     {
      for (int i = 0; i < items.Count; i++)
       {
        for (int j = i; j < items.Count; j++)
         {
          if (items[i].Text.CompareTo(items[j].Text) > 0)
           {
            string swap = items[i].Text;
            items[i].Text = items[j].Text;
            items[j].Text = swap;
            }
         }
       }
     }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Borralis
    Borralis avatar
    5 posts
    Member since:
    Dec 2011

    Posted 21 Mar 2012 Link to this post

    Hello Princy,

    Yes, thats it. That works great.

    Thanks
Back to Top