Hi,
I am working on WPF.\ and we are using telerik controls in our project.
we are implementing Expand all rows functionalaity in Telerik radgridview . In our radgridview few rows has childgrid and if we are using expandallhierarchyitems() method then it is expanding all rows. My requirment is when i click on expand all button then it shoud expand only those rows which have child grid control.
9 Answers, 1 is accepted
Have you checked this demo "SelfReference Hierarchy"?
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
i cant check that demo bcoz it is asking me for install Microsoft Silverlight Plugin.
I will explain my requirment in details.
Suppose my radgrid has 10 rows and only 4 rows childgrid has valu. there is one button expand all and when i clickd on expand all button then only 4 rows childgrid should be display remaining 6 rows should be collaped.
Actually you do not need Silverlight Plugin, because you are developing in WPF. If you have installed RadControls/WPF you may run Telerik WPF Examples demos locally. Furthermore you may also use the following link http://demos.telerik.com/wpf/. After installing it just find the demo SelfReference-Hirarchy in RadGridView's demos.
I believe that such case of hierarchy would be the most appropriate in your case.
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Thanks for your reply but my requirment is different.
In your example there is a "+" sign before all rows whose child grid has values.
but my requirment is There is only one button "Expand All Rows" and when i click on that button then only those rows which child grid contains value should be expand at a time means we no need to click on "+" sign of each row to expand that row.
Hi,
I have a problem i want to bind a hierahically class to a radgrid view, and i want the Workgroup items to show only the Workgroupname and fot the User items to show First Name, View, Edit properties.
public class User
{
public int Id
{
get;
set;
}
public string FirstName
{
get;
set;
}
public string LastName
{
get;
set;
}
public bool View
{
get;
set;
}
public bool Edit
{
get;
set;
}
public class Workgroup
{
public int Id
{
get;
set;
}
public string WorkgroupName
{
get;
set;
}
public ObservableCollection<Workgroup> Workgroups
{
get;
set;
}
public ObservableCollection<User> Users
{
get;
set;
}
}
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:telerik1="http://schemas.telerik.com/2008/xaml/presentation"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<Style TargetType="telerik:RadGridView">
<Setter Property="ShowGroupPanel" Value="False"/>
</Style>
</Grid.Resources>
<telerik:RadGridView x:Name="WorkgroupHierarchicalGridView" AutoGenerateColumns="False" DataLoading="WorkgroupHierarchicalGridView_DataLoading" ShowGroupPanel ="False">
<telerik:RadGridView.ChildTableDefinitions>
<telerik:GridViewTableDefinition>
<telerik:GridViewTableDefinition.Relation>
<telerik1:PropertyRelation ParentPropertyName="Workgroups" />
</telerik:GridViewTableDefinition.Relation>
</telerik:GridViewTableDefinition>
<telerik:GridViewTableDefinition>
<telerik:GridViewTableDefinition.Relation>
<telerik1:PropertyRelation ParentPropertyName="Users" />
</telerik:GridViewTableDefinition.Relation>
</telerik:GridViewTableDefinition>
</telerik:RadGridView.ChildTableDefinitions>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding WorkgroupName}" Header="Workgroup Name" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</Window>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.WorkgroupHierarchicalGridView.ItemsSource = WorkgroupsService.GetWorkGroups();
}
private void WorkgroupHierarchicalGridView_DataLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDataLoadingEventArgs e)
{
var dataControl = (GridViewDataControl)sender;
if (dataControl.ParentRow != null && dataControl.ChildTableDefinitions.Count == 0)
{
dataControl.ChildTableDefinitions.Add(new GridViewTableDefinition() { Relation = new PropertyRelation("Workgroups") });
dataControl.ChildTableDefinitions.Add(new GridViewTableDefinition() { Relation = new PropertyRelation("Users") });
}
}
}
You can apply a RowDetailsTemplateSelector and return different RowDetailsTemlpate base on some condition.
Please note you can download a runnable project of the demonstrated example from our online SDK repository here, after navigating to GridView/RowDetailsTemplateSelector. In order to make browsing the examples easier, you can take advantage of the SDK Samples Browser.
Let me know how this works for you.
Regards,
Dimitrina
Telerik
Hi unfortunately I didn't managed to implement the RowDetailsTemplate.(Now I'm learning WPF and telerik controls) .
The radgrid view loads a list of workgroup, that can host other workgroup and users.
I want the Workgroup to show only the workgroup name and an expander with other workgroups and users.
For the user i want to show only it's name,edit,view,delete propertis without showing the userId and the expander as it has no children underneath him.
Thank you.
You can manually define columns or in case the columns are auto-generated you can subscribe for the AutoGeneratingColumn event and cancel column generation if it should not be displayed.
As to not displaying an expand column for rows which does not have child data, you can check the Custom Hierarchy WPF Demos. You can also refer to the documentation on RadGridView.
Regards,
Dimitrina
Telerik