Ticket S31714
Visible to All Users

UI - Disable server-side operations (sorting, filtering, grouping, field chooser in the filter control, etc.) or provide warnings for non-persistent properties by default

created 16 years ago
Comments (1)
Dennis Garavsky (DevExpress) 14 years ago

    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

    Answers approved by DevExpress Support

    created 8 years ago (modified 5 years ago)

    We have implemented the functionality described in this ticket. It will be included in our next update(s).

    Please check back and leave a comment to this response to let us know whether or not this solution addresses your concerns.

    Additional information:

    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:

    1. The grid's Find Panel does not take non-persistent properties into account.
    2. 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.
    3. 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 Basic
    Imports 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; } }

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.