how to the tree list expand on click of checkbox column

2 posts, 0 answers
  1. sravanthi
    sravanthi avatar
    23 posts
    Member since:
    Aug 2010

    Posted 29 Aug 2011 Link to this post

    Hi Every one,

    I am trying to expand the list of the rows on click of the checkbox which is in the TreelistTempelatecolumn.I am not able to maintain the state of the variables.Can anyone help me please.

    This is what I am doing
    <telerik:RadPanelItem Value="CandidateInformation" runat="server">
                                <telerik:RadTreeList ID="rtlSpecsGroup" Width="40%" runat="server" DataSourceID="sdsTreeView"
                                        ParentDataKeyNames="PARENTID" AllowSorting="true" DataKeyNames="CATGROUPID" AllowMultiItemSelection="false"
                                     AutoGenerateColumns="false" OnItemDataBound="OnItemDataBound_rtlSpecsGroup" >
                                        <telerik:TreeListTemplateColumn UniqueName="chkTempelatecolumn" DataField="CATGROUPID" ItemStyle-Width="30px" HeaderStyle-Width="30px">
                                                <asp:CheckBox ID="chkGroups" runat="server" AutoPostBack="True" OnCheckedChanged="OnCheckedChanged_chkGroups"/>
                                        <telerik:TreeListBoundColumn UniqueName="NAME" HeaderText="Experience" DataField="NAME" ReadOnly="true"></telerik:TreeListBoundColumn>
                                        <telerik:TreeListTemplateColumn UniqueName="rblTempelatecolumn" HeaderText="YearsOfExperience">
                                                <asp:RadioButtonList ID="rblYearsOfExp" runat="server" Enabled="false" RepeatDirection="Horizontal" RepeatLayout="Flow">
                                                    <asp:ListItem Text="0-5" Value="1"></asp:ListItem>
                                                    <asp:ListItem Text="6-10" Value="2"></asp:ListItem>
                                                    <asp:ListItem Text="11-15" Value="3"></asp:ListItem>
                                                    <asp:ListItem Text="16-20" Value="4"></asp:ListItem>
                                                    <asp:ListItem Text="20+" Value="5"></asp:ListItem>
                                        <telerik:TreeListBoundColumn UniqueName="CATGROUPID" DataField="CATGROUPID" Visible="false" ReadOnly="true"></telerik:TreeListBoundColumn>
                                <telerik:RadButton ID="rbtnCINext" runat="server" Text="Next>>" OnClick="rbtnCINext_OnClick">
    on the code side this is what i am doing

        protected void OnCheckedChanged_chkGroups(object sender, EventArgs e)
            RadPanelItem CandidateInformation = rpbMainInfo.FindItemByValue("CandidateInformation");
            RadTreeList rtlSpecsGroup = (RadTreeList)CandidateInformation.FindControl("rtlSpecsGroup");
            ((sender as CheckBox).NamingContainer as TreeListDataItem).Selected = (sender as CheckBox).Checked;
                foreach (TreeListDataItem tlTreeName in rtlSpecsGroup.Items)
                    string ParentId = tlTreeName["CATGROUPID"].Text;
                    RadioButtonList rbtnlist = (RadioButtonList)tlTreeName.FindControl("rblYearsOfExp");
                    if ((sender as CheckBox).Checked == true)
                        if (tlTreeName.Selected == true)
                            if (ParentId == "1" || ParentId == "2" || ParentId == "3" || ParentId == "4")
                                tlTreeName.Expanded = true;
    what I am doing is On click of the check box I am trying to expand the parent item and also make the row selected.this part is working but the checkbox which I checked doesn't maintain.It returns the selected column with unchecked check box column.Itried with different styles but did not work out for me .Please let me know the best solution for the above problem

    Thanks InAdvance,
  2. Veli
    Veli avatar
    2002 posts

    Posted 01 Sep 2011 Link to this post

    Hello Sravanthi,

    This is because RadTreeList needs to rebind on expand/collapse. Rebinding recreates all the items and the controls inside. Hence, any control that gets recreated inside treelist items is in its initial state. This is why your CheckBoxes all default to their non-checked state. To preserve their checked state after databinding, you need to save each CheckBox's Checked property value to some variable on your page and then restore the Checked state after rebinding inside the ItemDataBound treelist event.

    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