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.
To enable filtering and sorting for non-persistent objects, you can use either the built-in DynamicCollection
class or a custom DynamicCollectionBase
descendant.
-
Create a
DynamicCollection
instance and pass it in the NonPersistentObjectSpace.ObjectsGetting event handler. -
Subscribe to the
DynamicCollection.FetchObjects
event and pass a new collection of non-persistent objects every time filter or sort parameters change. -
If you cannot filter the collection, set the
ShapeData
event parameter totrue
. TheDynamicCollection
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. -
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
andSorting
values passed in event parameters are converted to a storage-specific format and used as arguments of theDataTable.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 theShapeData
parameter of theDynamicCollection.FetchObjects
event is set totrue
. This approach is useful when all data is already available and no custom processing is required.
- How to implement CRUD operations for Non-Persistent Objects stored remotely in eXpressApp Framework
- How to edit Non-Persistent Objects nested in a Persistent Object
- How to: Display a List of Non-Persistent Objects
- How to filter and sort Non-Persistent Objects
- How to refresh Non-Persistent Objects and reload nested Persistent Objects
- How to edit a collection of Persistent Objects linked to a Non-Persistent Object
(you will be redirected to DevExpress.com to submit your response)