Ticket B152594
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

How to restore the Auto Filter Row from an active filter after restoring the layout

GridListEditor - How to restore values in the auto filter row

created 15 years ago (modified 9 years ago)

From a user:
"First of all, I must say that the GuessAutoFilterRowValuesFromFilter method is not supposed to be used directly in your code. This method is created for internal use only" -> i was pointed to this method and there is also an official example for it… -> How to restore the Auto Filter Row from the ActiveFilterString, after restoring the layout

Now start the App - filter the Contact via the Position column. If you have set the Filter click 2! times the Contact item in the Navigation bar - after the second click you will see that the filter is no longer visible, and if you click into the filter column you get an invalidcastexception because the value is now an string…?"

=====
You can use the following ViewController to replicate this error with our MainDemo.Win app:

C#
namespace MainDemo.Module.Win { using System; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Win.Editors; using DevExpress.Data.Filtering; public class B152594 : ViewController<ListView> { GridListEditor listEditor; protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); listEditor = View.Editor as GridListEditor; if(listEditor != null) { listEditor.Grid.HandleCreated += Grid_HandleCreated; } } private void Grid_HandleCreated(object sender, EventArgs args) { listEditor.Grid.HandleCreated -= Grid_HandleCreated; listEditor.GridView.GuessAutoFilterRowValuesFromFilter(); } } }

The following error will be thrown when restoring reference properties:

DevExpress.Xpo.v15.2.dll!DevExpress.Xpo.XpoObjectInCriteriaProcessingHelper.CriteriaOperator_UserValueParse_Core(DevExpress.Data.Filtering.UserValueProcessingEventArgs e) Unknown
  DevExpress.Xpo.v15.2.dll!DevExpress.Xpo.XpoObjectInCriteriaProcessingHelper.CriteriaOperator_UserValueParse(object sender, DevExpress.Data.Filtering.UserValueProcessingEventArgs e) Unknown
  DevExpress.Data.v15.2.dll!DevExpress.Data.Filtering.CriteriaOperator.DoUserValueParse(string tag, string data) Unknown
  DevExpress.Data.v15.2.dll!DevExpress.Data.Filtering.Helpers.CriteriaLexer.ExtractUserValue(string tag = "XpoObject", string data = "MainDemo.Module.BusinessObjects.Position({7c9c8d30-7c5c-4f69-b281-a6c09088f62e})") Unknown
  DevExpress.Data.v15.2.dll!DevExpress.Data.Filtering.Helpers.CriteriaLexer.DoUserObject() Unknown
  DevExpress.Data.v15.2.dll!DevExpress.Data.Filtering.Helpers.CriteriaLexer.Advance() Unknown
  DevExpress.Data.v15.2.dll!DevExpress.Data.Filtering.Helpers.CriteriaParser.yyparse(DevExpress.Data.Filtering.Helpers.yyInput yyLex = {DevExpress.Data.Filtering.Helpers.CriteriaLexer}) Unknown
  DevExpress.Data.v15.2.dll!DevExpress.Data.Filtering.Helpers.CriteriaParser.Parse(string query = "[Position!] = ##XpoObject#MainDemo.Module.BusinessObjects.Position({7c9c8d30-7c5c-4f69-b281-a6c09088f62e})#", bool allowSort) Unknown
  DevExpress.Data.v15.2.dll!DevExpress.Data.Filtering.Helpers.CriteriaParser.Parse(string stringCriteria, out DevExpress.Data.Filtering.OperandValue[] criteriaParametersList = null) Unknown
  DevExpress.Data.v15.2.dll!DevExpress.Data.Filtering.CriteriaOperator.Parse(string criteria, object[] parameters = {object[0]}) Unknown
  DevExpress.Data.v15.2.dll!DevExpress.Data.Filtering.CriteriaOperator.TryParse(string criteria, object[] parameters) Unknown
  DevExpress.XtraGrid.v15.2.dll!DevExpress.XtraGrid.Columns.ColumnFilterInfo.ColumnFilterInfo(DevExpress.XtraGrid.Columns.ColumnFilterType type = AutoFilter, object _value = {MainDemo.Module.BusinessObjects.Position}, string filterString = "[Position!] = ##XpoObject#MainDemo.Module.BusinessObjects.Position({7c9c8d30-7c5c-4f69-b281-a6c09088f62e})#", string displayText = "") Unknown
  DevExpress.XtraGrid.v15.2.dll!DevExpress.XtraGrid.Columns.ColumnFilterInfo.ColumnFilterInfo(DevExpress.XtraGrid.Columns.ColumnFilterType type = AutoFilter, object _value = {MainDemo.Module.BusinessObjects.Position}, string filterString = "[Position!] = ##XpoObject#MainDemo.Module.BusinessObjects.Position({7c9c8d30-7c5c-4f69-b281-a6c09088f62e})#") Unknown
  DevExpress.XtraGrid.v15.2.dll!DevExpress.XtraGrid.Views.Grid.GridView.GuessAutoFilterRowValuesFromFilter() Unknown

Comments (1)
Dennis Garavsky (DevExpress) 15 years ago

    Hello Noxe,
    I could collect four various scenarios in which the actual behavior seemed to be inconsistent. We will research them further, and let you know our results. Please bear with us.
    Thanks,
    Dennis

    Answers

    created 9 years ago (modified 9 years ago)

    Hello,

    To use the GridView.GuessAutoFilterRowValuesFromFilter method in an XAF WinForms app, consider the following ViewController:

    C#
    using System; using DevExpress.XtraGrid; using DevExpress.ExpressApp; using DevExpress.XtraGrid.Views.Grid; using DevExpress.ExpressApp.Win.Editors; namespace MainDemo.Module.Win { public class B152594 : ViewController<ListView> { GridListEditor gridlistEditor = null; protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); gridlistEditor = View.Editor as GridListEditor; if(gridlistEditor != null) { gridlistEditor.Grid.HandleCreated += Grid_HandleCreated; } } private void Grid_HandleCreated(object sender, EventArgs args) { GridControl grid = (GridControl)sender; grid.HandleCreated -= Grid_HandleCreated; using(var criteriaScope = View.ObjectSpace.CreateParseCriteriaScope()) { ((GridView)grid.MainView).GuessAutoFilterRowValuesFromFilter(); } } } }

    This will help you restore auto filter row values for reference properties as well.

      created 15 years ago (modified 9 years ago)

      Hello Noxe,
      We are afraid that we do not have good news on this issue. The XtraGrid Team said that the current implementation of the GuessAutoFilterRowValuesFromFilter method doesn't fully support the scenarios I showed in my previously attached videos and samples. Some info has already been provided in the similar GuessAutoFilterRowValuesFromFilter does not work with referenced values issue, and so we consider this to be the default behavior for this undocumented feature. Of course, we agree that it may be an improvement to address these scenarios, but we cannot do this right now, due to more important tasks.

      Thanks,
      Dennis

        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.