/XAF_Non-Persistent-Objects-Filtering-Demo

How to filter and sort non-persistent objects in XAF applications

Primary LanguageC#OtherNOASSERTION

XAF - How to filter and sort non-persistent objects

If a collection of non-persistent objects contains many items, you may need to filter it. However, built-in filters are disabled for non-persistent collections by default.

Warning

We created this example for demonstration purposes and it is not intended to address all possible usage scenarios. If this example does not have certain functionality or you want to change its behavior, you can extend this example. This can be a complex task that requires good knowledge of XAF: UI Customization Categories by Skill Level, and you may need to research how our components work. Refer to the following help topic for more information: Debug DevExpress .NET Source Code with PDB Symbols. We are unable to help with such tasks as custom programming is outside our Support Service scope: Technical Support Scope.

Implementation Details

To enable filtering and sorting for non-persistent objects, you can use either the built-in DynamicCollection class or a custom DynamicCollectionBase descendant.

  1. Create a DynamicCollection instance and pass it in the NonPersistentObjectSpace.ObjectsGetting event handler.

  2. Subscribe to the DynamicCollection.FetchObjects event and pass a new collection of non-persistent objects every time filter or sort parameters change.

  3. If you cannot filter the collection, set the ShapeData event parameter to true. The DynamicCollection then processes the data (filter, sort, and trim) internally.

    When you use the DynamicCollection, the built-in FullTextSearch action is displayed in corresponding non-persistent list views.

  4. The FindArticlesController in this example shows a custom search form with a lookup editor that allows filtering non-persistent objects in a lookup list view.

This example demonstrates two approaches to filter objects.

  • Contact objects are filtered at the storage level. Criteria and Sorting values passed in event parameters are converted to a storage-specific format and used as arguments of the DataTable.Select method call. DataSet returns filtered and sorted data that is then transformed into non-persistent objects. This approach can be useful when data for non-persistent objects is obtained from a remote service, a custom database query or a stored procedure.

  • Article objects are filtered and sorted internally by a DynamicCollection. This functionality is enabled when the ShapeData parameter of the DynamicCollection.FetchObjects event is set to true. This approach is useful when all data is already available and no custom processing is required.

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)