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

Filtering TreeViews

2 Answers 98 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Bra
Top achievements
Rank 1
Veteran
Bra asked on 08 Sep 2020, 01:17 PM

Hello,

I would like to filter a TreeView, but I can't find any solution for Xamarin.Forms. Is it possible or not ?

Thank you :)

2 Answers, 1 is accepted

Sort by
0
Lance | Senior Manager Technical Support
Telerik team
answered on 08 Sep 2020, 01:31 PM

Hi Bra,

The RadTreeView doesn't use FilterDescriptors or internal data segregation. Therefore, you can use normal filtering with LINQ.

For example:

//---------------------Setup------------------------- //
// Keep a separate ObservableCollection for TreeView

ObservableCollection<Car> originalData = ...;
ObservableCollection<Car> tvData = new ObservableCollection<Car>();
MyTreeView.ItemsSource = tvData;

//---------------------All Items---------------------- //

// show all the items in the Treeview
foreach(var car in originalData)
   tvData.Add(car);

//-------------------Filtered Items---------------------- //

// Clear the previous list
tvData.Clear();

// filter out the items you want
var filteredCars = originalData.Where(i => i.Make == "Mercedes Benz");

// show them in the Treeview
foreach(var car in filteredCars) 
   tvData.Add(car);

 

Regards,
Lance | Manager Technical Support
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Bra
Top achievements
Rank 1
Veteran
answered on 09 Sep 2020, 06:55 AM

Hi,

 

OK, I will implement my own filter. Thank you for your answer and the little example :)

Tags
TreeView
Asked by
Bra
Top achievements
Rank 1
Veteran
Answers by
Lance | Senior Manager Technical Support
Telerik team
Bra
Top achievements
Rank 1
Veteran
Share this question
or