View previous topic :: View next topic |
Author |
Message |
Advansys
Joined: 27 May 2011 Posts: 20
|
Posted: Fri Mar 15, 2013 6:14 am Post subject: Filtered items view |
|
|
We are using the Infralution Virtual Tree to display a large number of items and our data-source class implements the IList interface. We wish to add a feature which allows the user to enter text which is compared with item nodes and renders a filtered, hierarchical item view.
An example of our tree view:
Code: | - Contacts:
* Tony Abbott
* Julia Gillard
* Kevid Rudd
* Bill Smith
... (many more)
- Discussions:
* Mining tax
* Media reforms
* Education reforms
... (many more) |
We would like to find items easily from the list above and are considering the two approaches outlined below.
1. Once the user enters the search text, the tree view displays only the filtered items, maintaining parent-child relationship.
Example: Search text "reforms"
Tree view could show matches:
Code: | - Discussions:
* Media reforms
* Education reforms |
This is our preferred approach. Is it possible to filter the nodes displayed in the tree? If so, it would be most appreciated if you would share an outline of a technique that would fit our IList implementation.
2. The following is an alternative but not our preferred approach because it does not provide a filtered, hierarchical item view. Once the user enters the search text, locate matching items in the tree view and select the first item. We could have find next and previous buttons which basically finds & selects the next or previous matching item.
Below is a working technique for finding nodes in the tree. Can you suggest how the technique might be improved?
Code: | - Find the item in IList.
- Once the item is found, call virtual tree FindRow(node) to get the Row.
* If row not expanded, then expand it.
row.Expanded = true;
* Set the virtual tree selected row and set focus.
virtualTree.SelectedRow = row;
virtualTree.Focus(); |
Do you see any pros & cons of each approach listed above? Is there any other technique you would recommend?
Thank you for your advice.
Greg
Advansys |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Mar 15, 2013 7:34 am Post subject: |
|
|
Virtual Tree does not provide any way of hiding tree rows - because to do so would compromise performance when dealing with large data sources which is the main objective of Virtual Tree. Also filtering can often most efficiently done by the data source - for instance leverage database filtering. If you wish to implement filtering then you need to do this by changing the data returned by your data source IList implementations. So your UI code would set a property on the data source which indicates the filtering condition and your data source IList implementation would return a count of the items that meet that criteria. If your datasources don't implement IBindingList change notifications then after changing the filtering condition you would need to manually refresh the data displayed in the tree by calling VirtualTree.UpdateRows(). This forces the tree to reget all its data.
Your second option would also work and I can't see any major issue with your proposed implementation. _________________ Infralution Support |
|
Back to top |
|
|
Advansys
Joined: 27 May 2011 Posts: 20
|
Posted: Mon Mar 18, 2013 1:11 am Post subject: |
|
|
Thank you for your quick reply and suggestion, much appreciated.
Greg
Advansys |
|
Back to top |
|
|
|