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

return all Items

9 Answers 107 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Davood
Top achievements
Rank 1
Davood asked on 25 May 2011, 03:18 PM
hi
i need return all item rad tree view in hierarchical mode?

9 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 25 May 2011, 04:23 PM
Hello Davood,

Could you please elaborate more on your scenario ? Is your tree databound or it is populated declaratively ? Do you need to access only the root collection or you need to iterate in depth (perform some kind of search) ?

Kind regards,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Davood
Top achievements
Rank 1
answered on 26 May 2011, 03:32 PM

 

Thank you for your attention
my tree is databound
I need navigation all node tree and  put on a list<T> (node is type of T)
Recursively have it. But is very slow
Something like Outlook(inbox/sent/draft,..) tree  which dynamically node are added to the tree With the possibility of recovery and storage node
0
Davood
Top achievements
Rank 1
answered on 30 May 2011, 04:23 AM
No one will answer?
0
Petar Mladenov
Telerik team
answered on 31 May 2011, 02:19 PM
Hi Davood,

You can examine this demo showing how RadTreeView is used for navigation in a Master/Detail type of application. Furthermore, this demo shows RadTreeView used for navigation placed in OutlookBar.
You mentioned that you need recovery/storage mode. I guess you need to save the current state of the RadTreeView(selection, checking, expanded items, etc.) and use this state when needed, The good news is that this will be possible with the Persistance Framework that will be available in the Q2 2011 beta (scheduled for the middle of June). Feel free to ask if you need further assistance or info.

Kind regards,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Davood
Top achievements
Rank 1
answered on 31 May 2011, 04:13 PM
thank you for answer

but I did not notice, how can I navigate all rad tree node ( for example with foreach) ?
0
Tina Stancheva
Telerik team
answered on 06 Jun 2011, 07:50 AM
Hello Davood,

If by navigate you mean traverse the RadTreeView then you can use a foreach operator. Since the RadTreeView is databound, you can work with its ItemsSoucre collection and it will hold all your data items. In a databound RadTreeView most of the collection properties of the tree - ItemsSource, SelectedItems, CheckedItems hold the business objects.

I am not sure how your business model is defined but if you have a collection of DataItems bound to the ItemsSource RadTreeview collection and each DataItem has a Children collection property, you can:
foreach(DataItem item in radTreeView.ItemsSource)
{
  ...
  foreach(DataItem child in item.Children)
  {
   ...
  }
}
Is this what you had in mind or am I missing somethig?

Best wishes,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Davood
Top achievements
Rank 1
answered on 06 Jun 2011, 10:48 AM
Thank you very much for Attention and response.
my tree is:
<UserControl.Resources>
    <converters:BoolToVisibilityConverter x:Key="boolToVisibilityConverter"/>
    <Style x:Key="TreeViewItemStyle" TargetType="telerikNavigation:RadTreeViewItem">
        <Setter Property="IsExpanded" Value="{Binding IsExpanded}"/>
    </Style>
    <HierarchicalDataTemplate x:Key="TreeViewItemTemplate" ItemsSource="{Binding Items}">
        <StackPanel Orientation="Horizontal">
            <CheckBox IsChecked="{Binding Chart.Active}" Visibility="{Binding Chart.IsEnabled,Converter={StaticResource boolToVisibilityConverter}}">
                <CheckBox.Style>
                    <Style TargetType="CheckBox"
                   BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=CheckBox}}"/>
                </CheckBox.Style>
            </CheckBox>
            <TextBlock Text="{Binding Chart.ChartLevelTitle}" FontFamily="B Nazanin" FontSize="11" Margin="5 0 0 0"/>
            <TextBlock Text="{Binding Chart.Title}" />
        </StackPanel>
    </HierarchicalDataTemplate>
    <DataTemplate x:Key="EditTreeViewTemplate">
        <StackPanel Orientation="Horizontal">
            <TextBox Text="{Binding Chart.Title, Mode=TwoWay}" Margin="5 0 0 0" />
        </StackPanel>
    </DataTemplate>
</UserControl.Resources>
<Grid>
    <Border BorderBrush="Black" BorderThickness="1" Width="285" HorizontalAlignment="Left" CornerRadius="4">
        <telerikNavigation:RadTreeView IsEditable="True"  x:Name="treeView" IsExpandOnSingleClickEnabled="False"
                                   IsLineEnabled="True" IsDragDropEnabled="True" IsExpandOnDblClickEnabled ="True"
                                   ItemContainerStyle="{StaticResource TreeViewItemStyle}" IsTextSearchEnabled="True"
                                   ItemsSource="{Binding Items}" ItemTemplate="{StaticResource TreeViewItemTemplate}"
                                   ItemEditTemplate="{StaticResource EditTreeViewTemplate}">
            <telerikNavigation:RadContextMenu.ContextMenu >
                <telerikNavigation:RadContextMenu x:Name="contextMenu" ItemClick="OnItemClick" Opened="OnMenuOpened" FlowDirection="RightToLeft" >
                    <telerikNavigation:RadMenuItem Header="سطوح سازمان" IsEnabled ="False"  FontWeight="Heavy" />
                    <telerikNavigation:RadMenuItem IsSeparator="True" />
                    <telerikNavigation:RadMenuItem Header="درج" x:Name="insertNode" />
                    <telerikNavigation:RadMenuItem Header="سابقه" x:Name="historyNode" />
                    <telerikNavigation:RadMenuItem IsSeparator="True" />
                </telerikNavigation:RadContextMenu>
            </telerikNavigation:RadContextMenu.ContextMenu>
        </telerikNavigation:RadTreeView>
    </Border>
</Grid>
Possible to Create and remove and update the node by user is exists.
We need that after pressing confirm, all node which have been created by the user Add To list.
We had the following ways. that this method is slow:
public IList<Chart> GetChartsForInsert()
        {
            foreach (var item in treeView.Items)
            {
                RecursiveItems((item as Chart.InsertDataItem));
            }
  
            Singleton.Instance().BasMbs.CanInsertChart(_insertList);
            return _insertList;
        }
  
  
private void RecursiveItems(Chart.InsertDataItem dataItem)
        {
            foreach (Chart.InsertDataItem item in dataItem.Items)
            {
                if (item.Parent.Chart.Id != Guid.Empty)
                    item.Chart.ParentId = item.Parent.Chart.Id;
  
                if (item.IsNew)
                    _insertList.Add(item.Chart);
                else
                    _updateList.Add(item.Chart);
  
                if (item.Items.Count > 0)
                {
                    RecursiveItems(item);
                }
            }
        }
Please guide whether is way for return all RadTree node are?
0
Petar Mladenov
Telerik team
answered on 09 Jun 2011, 12:34 PM
Hello Davood,

I can see you are performing some kind of DFS iteration over the tree hierarchy which is not slow operation in the average case. I did not actually understand do you need to add into list only the items that you have edited. If so, you can add every Item immediately after the edit is completed. Could this fit in your scenario?

Regards,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Davood
Top achievements
Rank 1
answered on 12 Jun 2011, 04:20 AM
thank you for answer .My problem was solved
Tags
TreeView
Asked by
Davood
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Davood
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or