Ticket Q352044
Visible to All Users

Server and Instant Feedback Modes - Sort, Group and Filter by Non-Persistent Fields or In-Memory Values in Grid Controls

created 13 years ago (modified 5 years ago)

How This Works

In short, 'NO', it is not possible in a general case, and this permanent limitation is unrelated to DevExpress. Let's elaborate more:

  1. Database servers have no knowledge of values that exist only in memory on the client side (for instance, arbitrary C# or VB.NET logic in getters of calculated properties).
  2. Thus, database servers cannot physically execute sort, group and filter operations against such runtime values - SQL operates only against physical values stored in database tables and columns.
  3. In turn, DevExpress grid controls that are bound to Server or Instant Feedback data sources cannot sort, group and filter by columns bound to in-memory or runtime values. Unlike client mode, grids in Server or Instant Feedback Modes delegate all data manipulation operations to the underlying data layer (XPO, EF, LINQ to SQL, etc), which in turn constructs appropriate SQL statements and runs queries against supported database servers to retrieve small portions of data for the best speed and memory consumption (learn more…).

How To Handle Invalid Operations Against In-Memory Values

Sort, group and filter operations by grid columns bound to in-memory values that physically do not exist in the database should normally be disabled in Server or Instant Feedback Modes. To warn developers about invalid operations against database servers, XPO may throw the "Cannot query a data store using criterion (…)" error. To avoid this error, do one of the following:

1. Explicitly disable invalid operations at the grid control level (if it is impossible to express calculated column values via database values)

NOTE: XAF Grid List Editors automatically disables database server-side operations for non-persistent properties when DataAccessMode != Client. For more information, see PreventServerSideOperationsForNonPersistentMembers and S31714.

2. Express calculated column values via database values
In certain cases, C# or VB.NET logic in getters of calculated properties can be expressed using database fields or database functions.

  • Implement calculated properties in XPO classes with PersistentAliasAttribute.
  • If it is not possible to modify your XPO class code, implement calculated column at the grid control level with Unbound Expressions: WinForms, WPF and ASP.NET.

See Also

Server Mode Limitations (WinForms)
Server Mode Limitations (WPF)
Server Mode Limitations (ASP.NET WebForms)

Comments (3)
G G
Gilles Brice Mahabo 8 years ago

    Hello guys,

    I use the controller provide by Dennis and I use this method instead of the IsPersistent method :

    C#
    private bool LectureSeule(XafGridColumnWrapper column) { System.Reflection.PropertyInfo proper = typeof(MyClass).GetProperty(column.PropertyName); if (proper == null) return false; return !proper.CanWrite; }

    It's OK for the filtering, sorting and grouping in the gridview.

    But I have another problem, the property is always accessible in the "Filter Editor", so how can I deactivate my property (or all properties that are read-onl/non-persistent) in the "Filter Editor" ?

    G G
    Gilles Brice Mahabo 8 years ago

      It's OK guys, I find my answers in the ticket T342565.

      Dennis Garavsky (DevExpress) 8 years ago

        @Gilles Brice Mahabo: We are happy to hear of your results. I have also updated my answer to mention related XAF changes in v16.2.6/17.1.3.

        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.