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
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
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 >>
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.
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.
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.
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.
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.
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.
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;
}
http://docs.telerik.com/devtools/silverlight/common-export-support
Regards,
Peshito
Telerik
See What's Next in App Development. Register for TelerikNEXT.
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.
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.
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.
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.
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
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.
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
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.
Regards,
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
Hi Peshito,
Ok Thanks..
Bennit.