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

How to sync Treeview Contextmenu and Toolbar

19 Answers 203 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mattia
Top achievements
Rank 2
Mattia asked on 28 Aug 2013, 03:21 PM
Hi,
Is it possibile to keep syncronize treeview context menu and toolbar?

Example

1- Toolbar on Root node click
Icon1(Print Report) | Icon2(Delete) | Icon3(Modify)

2- Toolbar on node2.1 click
Icon1(Print Report) | Icon3(Modify)

TreeView

RootNode             -> ContextMenu:    Icon1 - Print Report
  |                                                         Icon2 - Delete
  |                                                         Icon3 - Modify 
  |_ node1
  |_ node2
        |_node2.1       -> ContextMenu
                                         Icon1 - Print Report
                                         Icon3 - Modify 


Thanks

19 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 28 Aug 2013, 11:44 PM
Hi Stefania,

You can definitely synchronize the RadTreeView and RadToolBar controls content. I'd suggest an approach where you use a common ViewModel and populate the RadTreeView with business items. If every business item contains a list of options, you can display those in a RadContextMenu and in a RadToolBar.

This means that you will have to populate the ItemsSource collections of the RadTreeView, RadContextMenu and RadToolBar with business data. And in order to make sure that the RadToolBar is displaying the options available for a selected node, you can bind its ItemsSource to a collection coming from the currently SelectedItem in the RadTreeView. For that purpose you can bind the RadTreeView SelectedItem to a business item from your view model and use that business item to populate the RadToolBar as well.

Please find a sample solution attached - it demonstrates the suggested approach. I hope it can help you get started.

Regards,
Tina Stancheva
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
bennit
Top achievements
Rank 1
answered on 29 Apr 2015, 09:10 AM
I have using Telerik “RadTreeView” in WPF application, I have try to print the Treeview with inside of scroll TreeViewItems, but printed “PrintVisual” only, so how can I take the print of full RadTreeView?
0
Peshito
Telerik team
answered on 30 Apr 2015, 11:57 AM
Hi,

The treeview uses virtualization which means that not all items will be presented in the visual tree until they are not needed to. This said, try to disable the Virtualization (IsVirtualizing=false). This is however recommended when the treeview is a smaller one. Keep the virtualization on  when the treeview is bigger one as this will increase its performance.

Regards,
Peshito
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
bennit
Top achievements
Rank 1
answered on 04 May 2015, 06:58 AM

Hi Peshito,

Thanks for your replay, My requirement is how to take the print inside of RadTreeView scorll items. Here i have attached screen Short, please help me. 

Thanks,

Bennit.

0
Peshito
Telerik team
answered on 05 May 2015, 07:27 AM
Hello,

There is not an out of the box way to do so. There is a workaround though that you could use. In your export method set the height of the control to double.NaN. This way the TreeView will act for a moment as there is no predefined height for it and you will be able to export its whole content. At the end of your method simply return its old height value.

Attached is a sample project illustrating the above approach.

As this topic is regarding "How to sync Treeview Contextmenu and Toolbar", I would suggest to open another topic regarding the current issue as it would be easier to follow.

Hope this helps.

Regards,
Peshito
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
bennit
Top achievements
Rank 1
answered on 05 May 2015, 10:58 AM

Hi Peshit,

Thanks, I can take print. Now we have using “telerik:RadGridView.RowDetailsTemplate” for look
like a hierarchical Grid. I need to Print the RadGridView and Export to Excel but I can’t do
that . Please find the attachment.

0
bennit
Top achievements
Rank 1
answered on 07 May 2015, 06:27 AM

Hi Peshito,

Thanks for your help, now i can take print. Now i have try to export  "RadTreeView" to excel but i have no Idea, Please check below code and help me.

 

<Window x:Class="Test.PrintTreeview"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        Title="PrintTreeview" >
    <Grid >
       
            <Grid x:Name="PrintGrid">
                
            <ScrollViewer Name="testScroll">
                <telerik:RadTreeView Name="terrview" Margin="0,0,0,61" BorderThickness="1" BorderBrush="Gray">
                   
                    <telerik:RadTreeViewItem Header="test1" IsExpanded="True">Name1

                    </telerik:RadTreeViewItem >
                    <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>

                </telerik:RadTreeView>
            </ScrollViewer>
        </Grid>
    
        <Grid>
            <Button Content="Print" Width="150" Height="30" Margin="60,230,82,10" Name="print" Click="print_Click" ></Button>
        </Grid>
    </Grid>

</Window>

 

 

Thanks,

Bennit.

0
bennit
Top achievements
Rank 1
answered on 07 May 2015, 10:19 AM

Hi Tina Stancheva,

I have using  Hierarchical "RadTreeView", My requirement is export RadTreeView to excel but i have no Idea, Please check below code and help me. 

<Window x:Class="Test.PrintTreeview"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        Title="PrintTreeview" >
    <Grid >
       
            <Grid x:Name="PrintGrid">
                
            <ScrollViewer Name="testScroll">
                <telerik:RadTreeView Name="terrview" Margin="0,0,0,61" BorderThickness="1" BorderBrush="Gray">
                   
                    <telerik:RadTreeViewItem Header="test1" IsExpanded="True">Name1

                    </telerik:RadTreeViewItem >
                    <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test2" IsExpanded="True">Name2</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test3" IsExpanded="True">Name3</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test4" IsExpanded="True">Name4</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test5" IsExpanded="True">Name5</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test6" IsExpanded="True">Name6</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test7" IsExpanded="True">Name7</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test8" IsExpanded="True">Name8</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test9" IsExpanded="True">Name9</telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="test10" IsExpanded="True">Name10</telerik:RadTreeViewItem>

                </telerik:RadTreeView>
            </ScrollViewer>
        </Grid>
    
        <Grid>
            <Button Content="Print" Width="150" Height="30" Margin="60,230,82,10" Name="print" Click="print_Click" ></Button>
        </Grid>
    </Grid>

</Window>

  Thanks,Bennit.

0
Peshito
Telerik team
answered on 07 May 2015, 10:38 AM
Hi,

The method below shows how to export the TreeView into Excel using Telerik's ExportExtentsons.
private void print_Click(object sender, RoutedEventArgs e)
   {
       var actHeight = terrview.ActualHeight;
       terrview.Height = double.NaN;
 
       string extension = "xlsx";
       SaveFileDialog dialog = new SaveFileDialog()
       {
           DefaultExt = extension,
           Filter = "*.xlsx)|*.xlsx"
       };
 
       if (dialog.ShowDialog() == true)
       {
           using (Stream stream = dialog.OpenFile())
           {
               Telerik.Windows.Media.Imaging.ExportExtensions.ExportToExcelMLImage(terrview, stream);
           }
       }
       terrview.Height = actHeight;
   }
More information about Exporting support can be found following the link below:
http://docs.telerik.com/devtools/silverlight/common-export-support

Regards,
Peshito
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
bennit
Top achievements
Rank 1
answered on 07 May 2015, 12:21 PM

 Hi Peshito, 

Thanks for your help, now I can export to excel as an image.But in “Infragistics” export to excel with editable option. I can Expand and Collapse the RadTreeView after export to excel this functionality in “Infragistics”. I need that same functionality in "Telerik", its possible please help me. Find the attachment.

Thanks,

Bennit.

 

0
bennit
Top achievements
Rank 1
answered on 07 May 2015, 12:27 PM

Hi Peshito, 

Thanks for your help, now I can export to excel as an image.But in “Infragistics” export to excel with editable option. I can Expand and Collapse the TreeView after export to excel this functionality in “Infragistics” control. I need that same functionality in "Telerik", its possible please help me. Find the attachment.

Thanks,

Bennit.

0
Peshito
Telerik team
answered on 11 May 2015, 07:55 AM
Hi,

You are welcome, Bennit. I am glad the exporting worked well. However the feature you referred to is not supported by the TreeView control and it is not editable after the export is done as it is exported as a picture.

Regards,
Peshito
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
bennit
Top achievements
Rank 1
answered on 21 May 2015, 12:44 PM

Hi Peshito,

You are right, I have using "Group By" concept to export the data to excel. But now I have another one question, how to remove the "MouseOver" color in RadTreeView? here I have post my code, but its not working..

 <Style TargetType="RadTreeViewItem">
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                           <Setter Property="Background" Value="White"></Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>

Regards,

Bennit.

 

 

 

 

0
Peshito
Telerik team
answered on 22 May 2015, 11:20 AM
Hello,

As I suggested earlier the topic of the forum thread is regarding "How to sync Treeview Contextmenu and Toolbar". As is switched on other topics several times I will ask you to start another forum thread for issues not related with this topic's matter.

Regarding the technical question about disabling the MouseOver state, it can be done by retemplating the TreeViewItemStyle. Attached is a sample project demonstrating this approach. What I did there was to remove the MouseOverVisual from the ControlTemplate.

Regards,
Peshito
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
bennit
Top achievements
Rank 1
answered on 26 May 2015, 10:16 AM

Hi Peshito,

Thanks for your help, now working fine. I have try to create a new forum thread but i don't know how to create new thread, please guide me.

I have one mode question,  how to remove the "MouseOver" color in RadGridView column Header? 

Regards,

Bennit.

0
Peshito
Telerik team
answered on 27 May 2015, 06:33 AM
Hi Bennit,

I am glad it is working well. As to your question about the MouseOver color and how to create new thread, this can be done by following the link below:
http://www.telerik.com/forums/wpf

Simply choose the appropriate product you would like to ask a question for and then click the "New thread" button in order to start the new thread. If your question is related with TreeView control, choose TreeView as a product and if it is about GridView, choose GridView as a product.

See attached pictures for more information.

Hope this helps.

Regards,
Peshito
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
bennit
Top achievements
Rank 1
answered on 27 May 2015, 07:46 AM

Hi Peshito,

Thanks for your help to created a "New thread", Now I have created New thread and post my question. please use this link to find the question.

http://www.telerik.com/forums/remove-mouseover-color-in-gridview-column-header#_ZAHPXDMcEe_7k-L7HKFSQ

Regards,

Bennit.

0
Peshito
Telerik team
answered on 27 May 2015, 10:26 AM
Hi Bennit,

Thank you for opening another thread regarding your last question regarding how to remove the "MouseOver" color in RadGridView column Header. Your will receive an appropriate answer shortly.

Regards,
Peshito
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
bennit
Top achievements
Rank 1
answered on 27 May 2015, 10:59 AM

Hi Peshito,

Ok Thanks..

Bennit.

Tags
TreeView
Asked by
Mattia
Top achievements
Rank 2
Answers by
Tina Stancheva
Telerik team
bennit
Top achievements
Rank 1
Peshito
Telerik team
Share this question
or