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

Custom Column with a TreeView selection editor

1 Answer 23 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Federico Gubellini
Top achievements
Rank 1
Federico Gubellini asked on 19 Dec 2018, 12:00 PM

Hi,
I need to implement a grid where the user can select a list of itemes from a TreeView. Once the items are selected, the cell must show the concatenation of selected items. Attached you can find a sample screenshot of what I need.

I tried to do that creating a custom column (https://docs.telerik.com/devtools/wpf/controls/radgridview/managing-data/how-to/howto-create-custom-editor). 
This is an extract from the code of my custom column.

 

public override FrameworkElement CreateCellEditElement(GridViewCell cell, object dataItem)
        {
            var treeView = new RadTreeView
            {
                IsOptionElementsEnabled = true,
                ItemsSource = TreeViewItemsSource,
                ItemContainerStyle = TreeViewItemContainerStyle,
                ItemTemplate = HierarchicalItemTemplate,
            };

            var dropDownButton = new RadDropDownButton
            {
                DropDownContent = treeView,
                DropDownMaxHeight = 250,
            };

            //this.BindingTarget = ???;

            return dropDownButton as FrameworkElement;
        }

My question is how to bind the checked items of the TreeView to the BindingTarget dependency property of the GridViewBoundColumnBase in order to update the field of the data item bound to the column, once the cell edit is committed.

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 21 Dec 2018, 12:57 PM
Hi Federico,

Thank you for the provided picture.

In general, you will need to bind the SelectedItems collection property of the RadTreeView to a custom collection of your business object. As the SelectedItems property is not bindable you can create custom behavior to sync the selected items with a collection from your view model. There is a SelectedItems SDK example in our GitHub repository which demonstrates how you can bind the SelectedItems property of the RadComboBox control to a collection from your view model. You can also check the BindingSelectedItemsFromViewModel SDK example which demonstrates how you can bind the SelectedItems property of the RadGridView.

You can try one of the suggested approaches and bind the RadTreeView SelectedItems in code behind.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Federico Gubellini
Top achievements
Rank 1
Answers by
Dinko
Telerik team
Share this question
or