This is a migrated thread and some comments may be shown as answers.

Radcombobox Grouping

8 Answers 565 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Prathap Narravula
Top achievements
Rank 1
Prathap Narravula asked on 07 Apr 2012, 01:32 PM

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

8 Answers, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 11 Apr 2012, 09:52 AM
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.
0
Prathap Narravula
Top achievements
Rank 1
answered on 11 Apr 2012, 11:59 AM
Hi Ivana,

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

0
Cat Cheshire
Top achievements
Rank 1
answered on 16 Apr 2012, 08:44 AM

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;
         
}
0
Arnie Vargas
Top achievements
Rank 1
answered on 08 Oct 2012, 08:15 PM
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)
0
Nencho
Telerik team
answered on 09 Oct 2012, 02:57 PM
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.
0
Arnie Vargas
Top achievements
Rank 1
answered on 09 Oct 2012, 03:56 PM
Thanks!

I will try and switch it around as I am populating from a datase
0
Eric D. Burdo
Top achievements
Rank 2
answered on 05 Jan 2017, 07:51 PM
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.

0
Nencho
Telerik team
answered on 10 Jan 2017, 09:26 AM
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.
Tags
ComboBox
Asked by
Prathap Narravula
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Prathap Narravula
Top achievements
Rank 1
Cat Cheshire
Top achievements
Rank 1
Arnie Vargas
Top achievements
Rank 1
Nencho
Telerik team
Eric D. Burdo
Top achievements
Rank 2
Share this question
or