Log In
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Report Server
[Collapse]eXpressApp Framework
 [Expand]Getting Started
 [Expand]Design-Time Features
 [Expand]Functional Testing
 [Collapse]Task-Based Help
  [Expand]Business Model Design
  [Expand]Application Model
    How to: Add a Search Action to Lookup Property Editors and Link Pop-up Windows
    How to: Add the Analyze Action to List Views
    How to: Create an Action Using the Action Attribute
    How to: Customize Action Controls
    How to: Customize the Export Action Behavior
    How to: Customize the New Action's Items List
    How to: Deactivate (Hide) an Action in Code
    How to: Disable an Action When the Current View Has Unsaved Changes
    How to: Hide the Edit Action Column from a ListView in an ASP.NET Application
    How to: Initialize an Object Created Using the New Action
    How to: Limit the Amount of Objects Created using the New Action
    How to: Make the FullTextSearch Action Search Within Required Properties
    How to: Reorder an Action Container's Actions Collection
    How to: Replace a List View's Default Action
  [Expand]List Editors
  [Expand]Property Editors
  [Expand]Scheduler and Notifications
  [Expand]Miscellaneous UI Customizations
  Frequently Asked Questions
 [Expand]API Reference
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Make the FullTextSearch Action Search Within Required Properties

This topic demonstrates how to customize the FullTextSearch Action's behavior. This Action filters the current List View by setting criteria for its collection data source. According to the criteria, the object's properties must contain individual words from the word combination typed by an end-user. Reference several techniques on how to modify the Action's behavior, in the FilterController.FullTextFilterAction member description. Here, you will see how to use one of these techniques. We will specify a custom list of the properties that will be used to generate the filter criterion for the current List View.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E231.

To specify a custom list of the properties that will be used in the search, the Filter Controller, which contains the FullTextSearch Action, exposes the FilterController.CustomGetFullTextSearchProperties event. To handle this event, we will add a new View Controller, and subscribe to its Controller.Activated event.

In the CustomGetFullTextSearchProperties event handler, assign a list of any required properties to the CustomGetFullTextSearchPropertiesEventArgs.Properties parameter. In addition, set the CustomGetFullTextSearchPropertiesEventArgs.Handled parameter to true, to indicate that other properties must not be added to the list. In this example, we will add only the "LastName" property of the Person class. So, we will activate our Controller for Person List Views only. The MyFilterController is shown below:

The following image demonstrate that the MyFilterController works:

Filtration may be impossible in case one or more property is of a particular type. For example, in Server mode, filtering by properties of the DateTime type, which are stored in a database as columns of the datetime date type, may cause exceptions. To avoid them, ensure that the inputed text can be converted to the corresponding type and this converted value is within the acceptable range, and exclude a property from the default filter list if necessary. The following code demonstrates the Controller implementing this logic.

Expanded See Also

How would you rate this topic?​​​​​​​