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

Parent items are already expanded when coming back with new search list.

2 Answers 18 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
HelloWorld
Top achievements
Rank 1
HelloWorld asked on 04 Jun 2013, 03:59 PM
Hello.

When I expand the icon for a set of standards, leave the results expanded, and then do a second standard search for a different standard the results are already partially expanded which are supposed to be not expanded as noted in attached pictures.

in code-hind

        /// <summary>
        /// Handler for the Search Button
        /// </summary>
        protected void SearchHandler(object sender, CriteriaController criteriaController)
        {
            if (radTreeResults.Visible)
            {
                if (DtGrid == null) DoSearch();

//DataView dv = new DataView(DtGrid, "ParentID is null", "", DataViewRowState.CurrentRows);                
                //radTreeResults.DataSource = dv;
                radTreeResults.DataSource = DtGrid;
                radTreeResults.DataBind();
            } 
            else
                radTreeResults.Visible = true;
        }
        
        protected void TreeListDataSourceNeeded(object sender, EventArgs e)
        {
            if (DtGrid == null) DoSearch(); 
            radTreeResults.DataSource = DtGrid;
        }
        protected void radTreeResults_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
        {
            if (e.Item is TreeListDataItem)
            {
                TreeListDataItem item = e.Item as TreeListDataItem;
                item.FindControl("lnkExpandAll").Visible = item.CanExpand;
                item.FindControl("lnkCollapseAll").Visible = item.CanExpand;
                if (item.Expanded)
                {
                    item.FindControl("lnkCollapseAll").Visible = item.Expanded;
                    item.FindControl("lnkExpandAll").Visible = false;
                }
            }
        }     

        protected void radTreeResults_ItemCommand(object sender, TreeListCommandEventArgs e)
        {
            if (e.CommandName == RadTreeList.ExpandCollapseCommandName)
            {
                if ((e.Item as TreeListDataItem).HierarchyIndex.NestedLevel == 0 && e.CommandArgument.ToString() == "ExpandAll")
                {
                    e.Canceled = true;
                    if (!(e.Item as TreeListDataItem).Expanded)
                    {
                        radTreeResults.ExpandItemToLevel((e.Item as TreeListDataItem), 10);
                    }
                    else
                    {
                        radTreeResults.CollapseAllItems();
                    }
                }
            }
        }

in .aspx

 <telerik:RadTreeList ID="radTreeResults" runat="server" ParentDataKeyNames="ParentID" Visible="False"
            DataKeyNames="StandardID" Skin="Office2010Silver"  Width="100%" Height="100%"
            AutoGenerateColumns="False" OnNeedDataSource="TreeListDataSourceNeeded" 
            OnItemCommand="radTreeResults_ItemCommand" OnItemDataBound="radTreeResults_ItemDataBound" ShowTreeLines="false">
            <ClientSettings Scrolling-AllowScroll="true" Scrolling-UseStaticHeaders="true">
                <Resizing ResizeMode="AllowScroll" AllowColumnResize="true" EnableRealTimeResize="true" />
                <Scrolling AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="true" ScrollHeight="560px" />
                <ClientEvents OnTreeListCreated="TreeListCreated" />
            </ClientSettings>
            <Columns>
                <telerik:TreeListSelectColumn HeaderStyle-Width="40px" UniqueName="SelectColumn">
                </telerik:TreeListSelectColumn>
                <telerik:TreeListTemplateColumn HeaderStyle-Width="120px" DataField="NameDisplayText"
                    UniqueName="NameDisplayText" HeaderText="Name" >
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkExpandAll" runat="server" CommandName="ExpandCollapse"
                            CommandArgument="ExpandAll" Text="+" Visible="true"></asp:LinkButton>
                        <asp:LinkButton ID="lnkCollapseAll" runat="server" CommandName="ExpandCollapse"
                            CommandArgument="CollapseAll" Text="-" Visible="false"></asp:LinkButton>
                        <asp:HyperLink ID="lnkStandardName" runat="server" Target="_blank" NavigateUrl='<%#"~/Record/StandardsPage.aspx?xID=" + Eval("EncryptedID") %>'
                            Visible="True" Style="color: Blue;" StandardID='<%# Eval("EncryptedID") %>' StandardName='<%# Eval("StandardName") %>' ><%# Eval("NameDisplayText")%></asp:HyperLink>                        
                    </ItemTemplate>
                </telerik:TreeListTemplateColumn>
                <telerik:TreeListBoundColumn HeaderStyle-Width="300px" DataField="StandardText" UniqueName="StandardText"
                    HeaderText="Text" />
                <telerik:TreeListBoundColumn HeaderStyle-Width="45px" DataField="Grade" UniqueName="Grade"
                    HeaderText="Grade" />
                <telerik:TreeListBoundColumn HeaderStyle-Width="100px" DataField="Subject" UniqueName="Subject"
                    HeaderText="Subject" />
                <telerik:TreeListBoundColumn HeaderStyle-Width="100px" DataField="Course" UniqueName="Course"
                    HeaderText="Course" />
                <telerik:TreeListBoundColumn HeaderStyle-Width="100px" DataField="Level" UniqueName="Level"
                    HeaderText="Level" />
                <telerik:TreeListBoundColumn HeaderStyle-Width="50px" DataField="ItemCount" UniqueName="ItemCount"
                    HeaderText="Items" />
                <telerik:TreeListBoundColumn HeaderStyle-Width="75px" DataField="ResourceCount" UniqueName="ResourceCount"
                    HeaderText="Resources" />
            </Columns>
        </telerik:RadTreeList>

2 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 07 Jun 2013, 02:33 PM
Hi Charlie,

I am afraid I was not able to understand the issue completely from the provided information and images. As far as I can see the TreeList is expanded in both images but populated with a different data. Are you trying to collapse all item after the second search? Additionally I examined the provided code and I wasn't able to find anything unusual. Could you please elaborate a little bit more on your scenario?

Regards,
Kostadin
Telerik
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 the blog feed now.
0
Robin
Top achievements
Rank 1
answered on 16 Jul 2013, 04:12 AM
I'm facing the same issue.

E.g.: In the first load, you have following rows displayed #1, 2, 3, 4, 5

You try to expand row #1, #2.

You also have a custom search and the search return 2, 3, 5.

In the result of the search, the #2, #3 will be expanded.

It seems that the TreeList preserve the expand/collapse state of each row in viewstate and auto-reload it during postback.

Perhaps, you should do TreeList1.CollapseAllItems(); when the Search is performed.
Tags
TreeList
Asked by
HelloWorld
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Robin
Top achievements
Rank 1
Share this question
or