In server modes, grid controls perform operations like sorting, grouping, filtering, etc. on the data store side to guarantee the best performance. Thus, columns bound to non-persistent properties (their values exist only in the client memory at runtime) cannot be used for such server-based operations and can cause exceptions (learn more…). Some of them can be detected only in the end application after navigating to a problematic grid at runtime.
With XAF 16.2.6, to prevent these situations, we have improved column creation logic in our Grid List Editors for Windows and the Web. In particular, we have disabled all server-based operations (sorting, filtering, grouping) for non-persistent properties in the ASP.NET WebForms ASPxGridListEditor and WinForms GridListEditor when DataAccessMode = Server or InstantFeedback. Technically, it means the following:
- The grid's Find Panel does not take non-persistent properties into account.
- The grid's Filter Editor does not display non-persistent properties in the properties tree.
3) The grid's Auto Filter Row feature is not available for non-persistent columns. - Grid column headers for non-persistent columns do not allow end-users to filter, sort, group.
See this video recorded from the WinForms version of our MainDemo:
Take special note that in XPO, calculated non-persistent properties defined using PersistentAliasAttribute or CalculatedAttribute can still be used without problems for server-based operations as previously. The only PersistentAlias attribute scenario, which may still not lead to disabled server-side operations, is when you have an aliased reference property and a grid column with a complex property path like: YourPersistentAliasReferenceProperty.SomeNestedProperty1.SomeNestedPropertyN. Such properties will be treated as regular non-persistent properties for now or you can disable our improvement using the feature toggle below.
For EF, calculated properties defined using CalculatedAttribute are still unsupported and treated as regular non-persistent properties mentioned above.
I do not need this behavior. How do I disable it?
With XAF v16.2.6 and v17.1.3, server-side operations for non-persistent properties are automatically disabled (ColumnsListEditor.PreventServerSideOperationsForNonPersistentMembers = true). If required, you can this property to False in the overridden OnActivated method of a custom ViewController for a required ListView. Refer to the following example:
C#using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
namespace MainDemo.Module.Controllers {
public class S31714_FeatureToggle : ViewController<ListView> {
protected override void OnActivated() {
base.OnActivated();
ColumnsListEditor columnsListEditor = View.Editor as ColumnsListEditor;
if(columnsListEditor != null) {
columnsListEditor.PreventServerSideOperationsForNonPersistentMembers = false;
}
}
}
}
Visual BasicImports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Editors
Namespace MainDemo.Module.Controllers
Public Class S31714_FeatureToggle
Inherits ViewController(Of ListView)
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
Dim columnsListEditor As ColumnsListEditor = TryCast(View.Editor, ColumnsListEditor)
If columnsListEditor IsNot Nothing Then
columnsListEditor.PreventServerSideOperationsForNonPersistentMembers = False
End If
End Sub
End Class
End Namespace
In some scenarios, the persistence of a member cannot be easily determined (e.g. an aliased property that uses a non-persistent property in its expression). In this case, the developer should explicitly disable operations not supported in server mode for this column. For example:
C#// YourSolutionName.Module.Web
public class ServerModeTuneListViewControllerWeb : ViewController<ListView> {
protected override void OnViewControlsCreated() {
base.OnViewControlsCreated();
var listEditor = View.Editor as ASPxGridListEditor;
if (listEditor != null && listEditor.Grid != null && View.CollectionSource.DataAccessMode != CollectionSourceDataAccessMode.Client) {
foreach (var columnWrapper in listEditor.Columns) {
var column = columnWrapper as ASPxGridViewColumnWrapper;
if (column != null) {
if (!IsPersistent(column)) {
column.Column.Settings.AllowAutoFilter = DevExpress.Utils.DefaultBoolean.False;
column.Column.Settings.AllowFilterBySearchPanel = DevExpress.Utils.DefaultBoolean.False;
column.Column.Settings.AllowGroup = DevExpress.Utils.DefaultBoolean.False;
column.Column.Settings.AllowHeaderFilter = DevExpress.Utils.DefaultBoolean.False;
column.Column.Settings.AllowSort = DevExpress.Utils.DefaultBoolean.False;
column.Column.Settings.ShowInFilterControl = DevExpress.Utils.DefaultBoolean.False;
}
}
}
}
}
private bool IsPersistent(ASPxGridViewColumnWrapper column) {
if (column.PropertyName == "NonPersistentProperty") return false;
return true;
}
}
C#// YourSolutionName.Module.Win:
public class ServerModeTuneListViewControllerWin : ViewController<ListView> {
protected override void OnViewControlsCreated() {
base.OnViewControlsCreated();
var listEditor = View.Editor as GridListEditor;
if (listEditor != null && listEditor.Grid != null && View.CollectionSource.DataAccessMode != CollectionSourceDataAccessMode.Client) {
foreach (var columnWrapper in listEditor.Columns) {
var column = columnWrapper as XafGridColumnWrapper;
if (column != null) {
if (!IsPersistent(column)) {
column.Column.OptionsFilter.AllowAutoFilter = false;
column.Column.OptionsFilter.AllowFilter = false;
column.Column.OptionsColumn.AllowGroup = DevExpress.Utils.DefaultBoolean.False;
column.Column.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
}
}
}
}
}
private bool IsPersistent(XafGridColumnWrapper column) {
if (column.PropertyName == "NonPersistentProperty") return false;
return true;
}
}
We have partially implemented this suggestion during the fix of the Application Model - Sorting is always applied to a List View column corresponding to a non-persistent property bug.
For now, only filtering and summaries are left untouched.
See Also:
Server Mode Limitations
Thanks,
Dennis