Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to search and focus nodes in the Tree List editor

$
0
0

Scenario:

By default, XAF provides the following capabilities to filter List Views: Filter List Views. In some cases, these filtering techniques may be inappropriate for a Tree List, since they filter records at the data source level without taking into account their tree structure. They also do not filter node's children, since child nodes are obtained from a persistent object's Children collection independently on a Tree List data source.
To overcome these limitations, it is possible to use the native TreeList filtering in WinForms (see Filtering) and cell templates customization in ASP.NET.

Steps to implement:

1. Create a ViewController for your Tree List ListView (WinFilterTreeListViewController and WebFilterTreeListViewController in this example).
2. Add actions allowing your users to apply filters to this ListView.
3. Handle the Execute event of these actions to customize the underlying TreeList control according to the required result.

In this example, the following functions are implemented:

WinForms:

 - Finding a node through the TreeList.FindNode method and focusing it. To test this function, enter a value in the FocusNode action and click the Focus button.
 - Applying a full text filter to the TreeList control through the TreeList.ApplyFindFilter method. To test this function, enter a value in the FindNode action and click the Find button.




It is also possible to use a native TreeList Find Panel instead of a ParametrizedAction for the full text filtering. Note that nodes will be filtered only if you set the TreeList.OptionsBehavior.EnableFiltering property to true. Otherwise, they will be only highlighted.
To change the way filtering is applied to the tree hierarchy, use the TreeList.OptionsFilter.FilterMode property.
If it is necessary to apply a filter only to certain columns, use the TreeList.ActiveFilterCriteria property instead of the TreeList.ApplyFindFilter method (see the commented code in the WinFilterTreeListViewController.findNodeAction_Execute event handler).
Note that since XAF loads child nodes dynamically when their parent is expanded, filters are not applied to collapsed children. That is why nodes are expanded before filtering in this example.

ASP.NET:

Since the ASP.NET TreeList control (ASPxTreeList) does not provide native filtering capabilities, this example demonstrates how to highlight nodes containing the specified text. This functionality is implemented through the ASPxTreeList.HtmlDataCellPrepared event, very similar to what is done in the non-XAF ASPxTreeList - How to create an external filter with the ASPxTextBox and highlighting search text example.  In the event handler, cell controls provided by XAF property editors are replaced with labels containing a highlighted text. Note that to highlight a text, a custom style is used. It is declared in the Default.aspx page through the <style> tag. If you do not add this style to your application, nodes will not be highlighted.


Question Comments

Added By: John Whattam 1 at: 6/17/2013 6:50:46 PM    

Where's the recursion?

Added By: Andrew Bingham 2 at: 11/3/2013 10:23:19 PM    

Goes into an inifinite loop


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>