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

3 posts, 0 answers
  1. HelloWorld
    HelloWorld avatar
    14 posts
    Member since:
    Jun 2013

    Posted 04 Jun 2013 Link to this post

    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. Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 07 Jun 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Robin
    Robin avatar
    10 posts
    Member since:
    May 2011

    Posted 15 Jul 2013 Link to this post

    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.
Back to Top