Item Groups In Combobox

10 posts, 0 answers
  1. Jeff
    Jeff avatar
    25 posts
    Member since:
    Feb 2011

    Posted 25 Aug 2011 Link to this post

    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?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Aug 2011 Link to this post

    Hello Jeff,

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

    Thanks,
    Shinu.
  3. Jeff
    Jeff avatar
    25 posts
    Member since:
    Feb 2011

    Posted 26 Aug 2011 Link to this post

    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?
  4. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 29 Aug 2011 Link to this post

    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 >>

  5. Jeff
    Jeff avatar
    25 posts
    Member since:
    Feb 2011

    Posted 29 Aug 2011 Link to this post

    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
  6. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 30 Aug 2011 Link to this post

    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 >>

  7. Jeff
    Jeff avatar
    25 posts
    Member since:
    Feb 2011

    Posted 30 Aug 2011 Link to this post

    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?
  8. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 31 Aug 2011 Link to this post

    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 >>

  9. Jeff
    Jeff avatar
    25 posts
    Member since:
    Feb 2011

    Posted 31 Aug 2011 Link to this post

    Very close...  but no checkboxes on the child nodes?!?
  10. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 01 Sep 2011 Link to this post

    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 >>

Back to Top