How to keep certain node collapsed?

3 posts, 0 answers
  1. Manoj
    Manoj avatar
    5 posts
    Member since:
    May 2011

    Posted 22 Feb 2012 Link to this post

    I am using TreeListView to show my data in hierarchical order. Here is simplified view of my xaml.

    <RadTreeListView>
      <RadTreeListView.ChildTableDefinitions>
         <TreeListViewTableDefinition  ItemsSource="{Binding PropertiesList, Mode=OneWay}"  />
      </RadTreeListView.ChildTableDefinitions>
      <RadTreeListView.Columns>
          <GridViewColumn>
              <GridViewColumn.CellTemplate>           
                <!-- My control to be shown in read only mode -->
              </GridViewColumn.CellTemplate>
              <GridViewColumn.CellEditTemplate>
                <!-- My control to be shown in Edit mode -->
              </GridViewColumn.CellEditTemplate>
          </GridViewColumn>
      </RadTreeListView.Columns>
    </RadTreeListView>

    So far everything works fine. Data is being shown properly. Only the issue is when data is shown my tree has data in following format.
    - section 1
      - item 1 in section 1
      - item 2 in section 1
      and so on items .....................
    - section 2
      - item 1 in section 2
      - item 2 in section 2
      and so on items .....................
    and so on sections........................

    These section are created programmatically. Once my data is loaded, I want to expand all sections except a particular one. The methods that can be called on TreeListView after data load are ExpandAllHierarchyItems() OR CollapseAllHierarchyItems(). But this is not what I need. How can I set a particular section to be collapsed in this case?

    I saw a method CollapseHierarchyItem() but I could not find the way to access that particular HierarchyItem and call this method on it. Could you please help out me with this issue?
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 27 Feb 2012 Link to this post

    Hello,

     You can iterate Items collection of the treelist to achieve your goal. 

    Kind regards,
    Vlad
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Manoj
    Manoj avatar
    5 posts
    Member since:
    May 2011

    Posted 27 Feb 2012 Link to this post

    Hi Vlad,

    Thanks for your reply. Could you please provide more details, which event should be used in this case to iterate and some sample code for it?

    Thanks,
    Manoj Attal
Back to Top