Checkboxes with IDs and labels

5 posts, 0 answers
  1. Holly
    Holly avatar
    11 posts
    Member since:
    Mar 2009

    Posted 30 Jun 2009 Link to this post

    Hi,
    I'm trying to get my website to the point where it is WCAG 2.0 AA compliant.
    To achieve this, checkboxes need to have associated labels. If I could allocate an ID to each checkbox within the treeview I could then force the the label via the name parameter when creating the node but I cannot see how to allocate that ID.
    Ie.
    From this
    <input type="checkbox" checked="checked" />
    <span class="TreeNode" title="Details of Internal Organisational Strucutre">Internal Organisational Structure 3</span>
    To
    <input type="checkbox" checked="checked" id = "chkone"/>
    <span class="TreeNode" title="Details of Internal Organisational Strucutre">
    <label for = "chkone">Internal Organisational Structure 3</label>
    </span>

    Is there a better/any way of doing this?
    Thanks
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 30 Jun 2009 Link to this post

    Hi Holly,

    You can achieve that by using the NodeTemplate of RadTreeView. I have attached a sample page demonstrating the required code. Make sure your checkbox has its CssClass property set to "rtChk" so RadTreeView recognizes it as its own checkbox. Also the CheckBoxes property should be set to false to avoid rendering of the built-in checkbox.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Holly
    Holly avatar
    11 posts
    Member since:
    Mar 2009

    Posted 30 Jun 2009 Link to this post

    Thanks Albert,
    That's nearly perfect :c)
    Is there anyway to do this from the server side? I have code-behind that automatically populates the tree view, where some of the nodes should have check boxes but most not.
    If need be, I can probably manage to do this via placeholders, but would rather not if there is a less roundabout route.
    Thanks again
  4. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 01 Jul 2009 Link to this post

    Hi Holly,

    You can just instantiate the required controls and add them to the node's Controlls collection. Just make sure the properties are set right.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Philip Jones
    Philip Jones avatar
    7 posts
    Member since:
    Dec 2005

    Posted 14 Jul 2009 Link to this post

    Hi there

     

    It seems to be the same problem I am having right now. I have the latest RadTreeView component on my page and I am using certain client events e.g. "OnClientNodeChecked" in order to check the children and parent nodes according to the requirements

    As part of the WCAG compliance, I have to associate labels with the checkboxes as well. I tried the suggested solution of having checkboxs and labels inside the NodeTemplate and setting the Cssclass to "rtChk".

    It associated the checkbox with the label successfully; However the client event of OnClientNodeChecked stopped working. Is there any other way to achieve this i.e. associating the built-in checkboxes to labels.

    Thanks in advance.

    Regrads

Back to Top