Server and InstantFeedback Modes
- 5 min to read
In the Server mode, a List View does not have simultaneous access to all the objects of the ListView.CollectionSource's type. Only those objects that are currently visible are loaded in small portions on demand. Each operation that assumes that new visible objects appear (scrolling, paging, grouping, sorting), requires additional data requests. Data-aware operations (grouping, sorting, etc.), are performed by the database server and significantly increases the List View's performance when working with a large number of objects. In this mode, all properties are calculated when it is required (only the visible in the GridView and that is used in the Appearance, Security rules, etc).
In Mobile applications, only the Server mode is supported.
In the InstantFeedback mode, a List View does not have simultaneous access to all the objects of the Collection Source's type as well as in the Server mode. The data-aware operations are performed asynchronously in the background thread, and the control continues responding to a user's actions, while data is being retrieved. By default, the CollectionSourceBase.DisplayableProperties property contains property names from the source collection. In XPO, these are the names of all visible properties and properties listed in XPInstantFeedbackSource.DisplayableProperties. In EF, only visible properties are listed by default. Unlike the Server mode, these lists are populated at once before the grid data is displayed. As a result, all properties listed in CollectionSourceBase.DisplayableProperties can be accessed without additional database requests.
Expected Behavior (Server and InstantFeedback Modes)
- If you use a legacy database whose table has a primary compound key, such a table cannot be used to supply data in Server or InstantFeedback mode.
- If you have a custom Controller that accesses the List Editor's control of a List View to perform custom sorting or grouping, the Controller may no longer work, since the database server performs grouping and sorting. Custom summaries are also calculated on the server side.
- Controls that support the Server and InstantFeedback modes do not have full access to underlying data and cannot initiate the filtering, sorting and grouping operations on the client side. These operations are delegated to the underlying ORM (Entity Framework or XPO), which constructs an appropriate SQL statement and performs a query to the SQL server to retrieve a small portion of data that should immediately display to the user. You cannot filter, sort and group data against non-persistent properties - it is not possible to build a SQL query against a runtime value existing on the client side only, and execute it on the database server. Filtering, grouping and sorting operations are disabled if a property is non-persistent.
- Two built-in List Editors currently support the Server mode: the GridListEditor, used by default in WinForms applications, and the ASPxGridListEditor, used by default in ASP.NET Web applications. The InstantFeedback mode is compatible with the WinForms GridListEditor only.
- If you want the Server or the InstantFeedback mode to display a nested List View, make sure that there is no logic for sorting, filtering or anything else in the getter of the underlying collection, and there are no subscribers to the collection's events. This logic and subscribers won't be taken into account, because a standalone server collection will be created instead of the original collection.
An independent server-mode collection is created as a data source for a lookup ListView when the IModelListView.DataAccessMode option is set to Server or InstantFeedback for that ListView model. However, when the DataSourcePropertyAttribute is applied for the lookup property, the property pointed in the attribute is used as a lookup data source, and the standalone independent server-mode collection is not created and is not used at all. The reason is that the data source property getter contains logic calculated on the client side and the data source is populated by the client application at the moment when the lookup editor requests to display objects. So, the Server or InstantFeedback mode option and the DataSourceProperty attribute do not work simultaneously.
InstantFeedback Mode's Specificities
- The View.CurrentObject and View.SelectedObjects properties return XafInstantFeedbackRecord objects instead of original business objects. To get the real object, use the IObjectSpace.GetObject method.
Inline editing is not supported in this mode. If an original object was modified, it does not display in a List View until you commit changes and reload the collection.
For example, when an Action changes an object's property value, this object's instance is created by the separate database request and the property value's modification is not displayed on a grid until you commit changes (or it occurs automatically if the BaseObjectSpace.CommitChanges property is set to true).
If the Appearance and Security rules are applied to an object type in the current List View, and those criteria use objects' properties that are not contained in the CollectionSourceBase.DisplayableProperties collection, these objects' instances are created by the separate database request to check each rule.
- In XPO, the default InstantFeedback mode behavior may cause performance issues. Properties which are hidden in the UI but are listed in CollectionSourceBase.DisplayableProperties may have complicated logic in getters which requires a large amount of database requests. You can change the default behavior using the XPObjectSpace.InstantFeedbackMappingMode property.
- In Entity Framework or XPO, when the XPObjectSpace.InstantFeedbackMappingMode value is RequiredProperties and required calculated properties are invisible, add them to the CollectionSourceBase.DisplayableProperties list. Otherwise, additional database requests may occur.
- Reference properties are automatically replaced by default properties of the corresponding reference objects when sorting, grouping and filtering. For instance, in the Contact List View, the Contact.Department.Title property is used instead of Contact.Department.
- The OpenObjectController.OpenObject Action is inactive in this mode.
If you use the Entity Framework as your ORM system and InstantFeedback data access mode, implement Aggregated collections' cascade deletion as described in the Cascade Deletion for Aggregated Entities section of the Relationships Between Entities in Code and UI topic.