Radcombobox Grouping

9 posts, 0 answers
  1. Prathap Narravula
    Prathap Narravula avatar
    23 posts
    Member since:
    Apr 2010

    Posted 07 Apr 2012 Link to this post


    I want to fill my radcombobox with grouping like category and items which should get from database.
    Please find the attachment for the reference
    example :
    category1
       --Item1
       --item2
    Category2
       --item1
       --item2
    Category3
        --item1
        --item2
        --item3

    Thanks
    Prathap
  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 11 Apr 2012 Link to this post

    Hi Prathap,

    You could use the IsSeparator property of RadComboBoxItem. Here is an example:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="200">
        <Items>
            <telerik:RadComboBoxItem Text="item1" IsSeparator="true"/>
            <telerik:RadComboBoxItem Text="item1.1" />
            <telerik:RadComboBoxItem Text="item1.2" />
            <telerik:RadComboBoxItem Text="item1.3" />
            <telerik:RadComboBoxItem Text="item2" IsSeparator="true"/>
            <telerik:RadComboBoxItem Text="item2.1" />
            <telerik:RadComboBoxItem Text="item2.2" />
            <telerik:RadComboBoxItem Text="item2.3" />
        </Items>
    </telerik:RadComboBox>

    I hope this helps.

    All the best,
    Ivana
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Prathap Narravula
    Prathap Narravula avatar
    23 posts
    Member since:
    Apr 2010

    Posted 11 Apr 2012 Link to this post

    Hi Ivana,

    Thanks for your reply..
    I need to fill the dropdown values from database. How do i write Issperator=true.

  4. Cat Cheshire
    Cat Cheshire avatar
    128 posts
    Member since:
    Jun 2010

    Posted 16 Apr 2012 Link to this post


    You can handle the combo ItemDatabound event and set the item IsSeparator property:
    protected void RadComboBox2_ItemDataBound(object sender, Telerik.Web.UI.RadComboBoxItemEventArgs e)
    {
             
        RadComboBoxItem item = e.Item;
     
        if(item.Text.Contains("Category"))
            item.IsSeparator = true;
             
    }
  5. Arnie Vargas
    Arnie Vargas avatar
    7 posts
    Member since:
    Oct 2012

    Posted 08 Oct 2012 Link to this post

    How would this work for a field which has the separator in a different field?

    For example I have a list of people and they have each have a TITLE value which is their position.

    --Doctors(Title column)
      --Doctor #1 (name column)
      --Doctor #2 (name column)
    --MA(title column)
      --MA #1(name column)
      --MA #2(name column)
    --RECEPTION(title column)
      --Receptionist #1(name column)
      --Receptionist #2(name column)
  6. Nencho
    Admin
    Nencho avatar
    1620 posts

    Posted 09 Oct 2012 Link to this post

    Hi Arnie,

    I have prepared a sample project for you, in order to demonstrate you how to implement the desired functionality. Please note that RadComboBox is not a hierarchical control and implementing the suggested approach could be a tricky task.

    All the best,
    Nencho
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Arnie Vargas
    Arnie Vargas avatar
    7 posts
    Member since:
    Oct 2012

    Posted 09 Oct 2012 Link to this post

    Thanks!

    I will try and switch it around as I am populating from a datase
  8. Eric D. Burdo
    Eric D. Burdo avatar
    2 posts
    Member since:
    Sep 2011

    Posted 05 Jan Link to this post

    private void LoadAssigneeList() {
      List<AssigneeModel> lstAll = GetAssignees();
      ddlCombinedAssignees.Items.Clear();   //Remove all the items, so we don't load more than once
     
      //Add a new category when it changes
      int teamCat = -1;
      foreach (var item in lstAll) {
        if (item.TeamID != teamCat) {
          teamCat = item.TeamID;
          var itmCat = new RadComboBoxItem(item.TeamName, item.TeamID.ToString());
          itmCat.IsSeparator = true;
          ddlCombinedAssignees.Items.Add(itmCat);
        }
     
        var itm = new RadComboBoxItem(item.LastFirst, item.UserID);
        ddlCombinedAssignees.Items.Add(itm);
      }
    }

     

    Here is a method I use.  The "GetAssignees" routine is a class or model.  It has four properties:  LastFirst, UserID, TeamName, TeamID.

    I want my categories to be the TeamName, and the items to be the Name (with UserID as the value).

    GetAssignees talks to the DB and populates a List<> of the Assignees... I then walk through that to populate the RadComboBox.

  9. Nencho
    Admin
    Nencho avatar
    1620 posts

    Posted 10 Jan Link to this post

    Hello Eric,

    Thank you for sharing your solution with the community!

    Regards,
    Nencho
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top