Can we add treeview in the gridview

1 Answer 95 Views
CheckBox DataGrid Expander TreeView
purushotham
Top achievements
Rank 1
purushotham asked on 08 Jul 2023, 02:32 PM

  <telerik:RadDataGrid x:Name="dataGrid"
                         ItemsSource="{Binding People}">
        <telerik:RadDataGrid.GroupHeaderTemplate>

              <telerik:RadTreeView x:Name="treeView" 
                         ItemsSource="{Binding Items}" 
                         CheckBoxMode="Recursive">
        <telerik:TreeViewDescriptor DisplayMemberPath="Name"
                                    ItemsSourcePath="Children"
                                    TargetType="{x:Type local:Item}" />
        <telerik:RadTreeView.BindingContext>
            <local:ViewModel/>
        </telerik:RadTreeView.BindingContext>
    </telerik:RadTreeView>


        </telerik:RadDataGrid.GroupHeaderTemplate>        
    </telerik:RadDataGrid>

 

 

 public class Item
    {
        public Item(string name)
        {
            this.Name = name;
            this.Children = new ObservableCollection<Item>();
        }

        public string Name { get; set; }
        public IList<Item> Children { get; set; }
    }        

 

 

 

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
    public Gender Gender { get; set; }
}

1 Answer, 1 is accepted

Sort by
1
Accepted
Lance | Senior Manager Technical Support
Telerik team
answered on 10 Jul 2023, 05:30 PM

Hi Purushotham,

This is not currently possible in the GroupHeaderTemplate of the .NET MAUI DataGrid control. The primary reason is you will not get the unlimited vertical space you're looking for.

Ultimately, what you show in the screenshot is called a "TreeListView". We do not currently have one for .NET MAUI, if this is a requirement for a desktop application, you could consider using Telerik U for WPF, which does have exactly that control, see => WPF TreeListView - Overview - Telerik UI for WPF

Note: If you did want to keep trying to use the RadTreeView for .NET MAUI, you could look into customizing the ItemTemplate... but keep in mind that there are no columns. So you cannot click a "column header" and get sorting like feature for the column. If you'd like to see source code for a demo that uses the ItemTemplate, see the Emails demo here => maui-samples/Samples/ControlsSamples/Examples/TreeViewControl/FirstLookExample/EmailsView.xaml.

Regards,
Lance | Manager Technical Support
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
CheckBox DataGrid Expander TreeView
Asked by
purushotham
Top achievements
Rank 1
Answers by
Lance | Senior Manager Technical Support
Telerik team
Share this question
or