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

Item Groups In Combobox

9 Answers 165 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 25 Aug 2011, 07:47 PM
I have a need to have groupings in a combobox.   IE Users:  3 groups -  Admins, SuperUsers and Users with section headers and checkboxes for each user like this demo:  http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/templates/defaultcs.aspx

I would also like to have a checkbox at each section header to act as a check or uncheck all for that section.

Is this possible?

9 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Aug 2011, 06:05 AM
Hello Jeff,

Check the following Code-Library which implements similar scenario
Combobox with checkboxes and select all

Thanks,
Shinu.
0
Jeff
Top achievements
Rank 1
answered on 26 Aug 2011, 01:25 PM
Shinu,

That is cool thanks. Is there a way to do multiple groupings in the same combo?  

ie.a header with select all, titled administrators, and another one with a select all with users.etc?
0
Ivana
Telerik team
answered on 29 Aug 2011, 02:03 PM
Hi Jeff,

I have made an example page showing how to implement multiple groupings in the ComboBox. For the implementation of this scenario I am using RadTreeView as an item template of the RadComboBox.

Attached is only the .aspx file.

Hope this helps.

All the best,
Ivana
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Jeff
Top achievements
Rank 1
answered on 29 Aug 2011, 05:58 PM
Can I get the datasource definition of what you are using or can you tell me how to set it for my need:

User table,   UserID, UserName, RoleID

Role table,  RoleID,  RoleName

RoleName should be the category for the header fields and user split
0
Ivana
Telerik team
answered on 30 Aug 2011, 02:43 PM
Hello Jeff,

You can not bind the RadTreeView to two DataSources. The structure of the DataSource the control is bound to should have the same structure as the DataTable shown in the following help article: Binding to Hierarchical Data.

In your case a possible approach could be creating two DataSources, one that gets the data from the "User" table and the other from the "Role" table. Having that you can create a DataTable object and populate it with the following data: UserID, UserName, RoleID, RoleName and bind the RadTreeView to it.

You can find examples showing how to create a DataTable and bind the RadTreeView to it at the "Binding to Hierarchical Data" link above.

Regards,
Ivana
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Jeff
Top achievements
Rank 1
answered on 30 Aug 2011, 04:35 PM
I guess I am not following.  I have a single dataset being returned from a SQL call where I join the tables.

I have:   UserID, UserName, RoleID, RoleDescription

I want the RoleDescription to be the category of users (ie. the tree nodes) and I want the users with that RoleID to be under that category. 

I need the UserName to be the text displayed with the UserID as the value.

Can you tell me what would be what in the ID Bindings with that setup?

ie. What would these be:   DataFieldID, DataFieldParentID, DataTextField (UserName?), DataValueField (UserID?) 

RadTreeNodeBinding Category="RoleDescription" ??

OR Should I look at a RadGrid inside the combo approach?
0
Ivana
Telerik team
answered on 31 Aug 2011, 02:36 PM
Hi Jeff,

You may need to recreate the data set you have gained from joining the tables:
Users: UserID, UserName, RoleID; and
Roles: RoleID, RoleName;

A possible approach could be, to create a data set that will have the following structure (the result of the execution of the  queries given bellow):
"Select ParentID = null, ID = RoleID, Name = RoleName, Description = RoleName from Roles"
+ "union all" +
"Select ParentID = RoleID, ID = UserId, Name = UserName, Description = null from Users"
So the structure of the result set will be:
ParentID, ID, Name, Description 

*Please note that in this case the description of the roles is set to its role name,and the users don't have description i.e
  ParentID    ID      Name       Description
   null      1     Managers       Manager
   null      2     Programmer    Programmer
    1        3       John          null
    2        3       Steve         null

Now you can set the properties of the radTreeView to the following values:
DataTextField = "Name";
DataValueField = "Description";
DataFieldID = "ID";
DataFieldParentID = "ParentID";

Hope this helps.

Kind regards,
Ivana
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Jeff
Top achievements
Rank 1
answered on 31 Aug 2011, 09:42 PM
Very close...  but no checkboxes on the child nodes?!?
0
Ivana
Telerik team
answered on 01 Sep 2011, 02:28 PM
Hi Jeff,

If you remove the RemoveCheckBoxes(node) JavaScript method and comment the call to it in the method OnClientLoad(sender, args) it should show the check boxes on the child items also.

You could also refer to the following help article to see how to deal with the check boxes in the RadTreeView control:  Check Boxes in a RadTreeView.

Regards,
Ivana
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
ComboBox
Asked by
Jeff
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jeff
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or