Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • I tried to improve performance (regarding to http://www.devexpress.com/Support/Center/Issues/ViewIssue.aspx?issueid=Q351945) by using XPServerCollectionSource but I've got exception like "Cannot query a data store using criterion "[DateOfOrder] >= AddDays(#2011-11-02 13:47:09.65577#, -7.0)" that uses a non-persistent property 'DateOfOrder'.: and also sorting on non persistent were disabled.

                                    Is there anything which can be done to fix or workaround this issue?

                                    Best Regards,

                                1 Solution

                                Creation Date Rating Importance Sort by
                                0
                                Hello Krzysztof,

                                 

                                Thank you for contacting us. Controls that support the Server Mode 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 (XPO in this case), which constructs an appropriate SQL statement and performs a query to the SQL server to retrieve a small portion of data that should be immediately displayed to the user.

                                XPO does not support server-side filtering, sorting and grouping against non-persistent properties, because it is not possible to build a SQL query against a runtime value (physically, the value existing on the client side only) and execute it on the database server.

                                In most scenarios, it is not required to allow users to filter, group, sort data or search by calculated columns. These operations are disabled by default in Server Mode if a property is not persistent. This error might occur if these operations were accidentally unlocked. For example, it is possible to explicitly unlock sorting by a certain column in the WinForms GridControl by setting the AllowSort column option to DefaultBoolean.True. Another scenario is when filters or sorting based on non-persistent properties were defined for client-mode grids, but the view's Data Access Mode is changed to Server or DataView later. In this situation, the end user may face the error when navigating to such a view. To avoid it, drop user model customizations when upgrading the application (see Convert Application Model Differences).

                                If these operations are unlocked without purpose, the solution is simple. Explicitly disable the sorting, filtering and grouping operations for such columns. Controls that support the Find Panel also provides the capability to exclude certain columns from the find filter. For the WinForms GridControl, this option is in the GridView class: GridView.OptionsFind.FindFilterColumns.

                                In case these operations were enabled on purpose, another solution is available. While it is not possible to sort, filter and group data by non-persistent fields at the database server level for obvious reasons, in certain cases, it is possible to re-implement such properties to express their values via persistent fields. Please check out the PersistentAliasAttribute Class documentation for more details on how it can be done when XPO is used for data access.

                                Adding a PersistentAliasAttribute to the property is a minor change, but if it is not acceptable for some reason, it is possible to implement a calculated column at the control level without modifying the business model class. For this purpose, we offer a special feature named Unbound Expressions. This feature is supported in our WinForms, WPF and ASP.NET components. Unbound Expressions are fully supported in Server Mode.

                                UPDATED:

                                Starting with XAF v16.2.6 and v17.1.3, server-side operations for non-persistent properties are automatically disabled: UI - Disable server-side operations (sorting, filtering, grouping, field chooser in the filter control, etc.) or provide warnings for non-persistent properties by default. See also: ColumnsListEditor > PreventServerSideOperationsForNonPersistentMembers 


                                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#]
                                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#]
                                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; } }



                                See Also:
                                Server Mode Limitations
                                Server Mode Limitations (WPF)

                                Thanks,
                                Dennis

                                • Gilles Brice Mahabo 06.02.2017
                                  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" ?
                                • Gilles Brice Mahabo 06.02.2017
                                  It's OK guys, I find my answers in the ticket T342565.
                                • @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.

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners