sort tabs in tabstrip

2 posts, 0 answers
  1. beeta one
    beeta one avatar
    63 posts
    Member since:
    Aug 2012

    Posted 07 Dec 2012 Link to this post

    1)how to sort tabs alphabeticaly in a tabstrip?  
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Dec 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;
            }
         }
       }
     }

    Hope this helps.

    Regards,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top