Bug Report B143361
Visible to All Users

GuessAutoFilterRowValuesFromFilter does not work with referenced values

created 15 years ago

Hi,
the GuessAutoFilterRowValuesFromFilter does not work correctly if the filter value is an referenced property. I have an column "Contact" - which is a referenced property to the contacts table. if i filter the column and filter is created like [Document.Contact]='MyContact' -> the right operand is the instance of the selected contact. If i call now GuessAutoFilterRowValuesFromFilter, the last line of this method if the problem i think:
column.FilterInfo = new ColumnFilterInfo(ColumnFilterType.AutoFilter, obj3, filterInfo.FilterString);
Here obj3 is correctly my contact instance - but this constructor takes the FilterString as parameter and converts the contact criteria to a string value, so [Document.Contact]='MyContact' -> MyContact is an string value now. So im wondering why dont you use CreateAutoFilterCriterion method instead filterInfo.FilterString or even the CreateFilterRowInfo() method?

Show previous comments (11)
M M
Martin Praxmarer - DevExpress MVP 15 years ago

    Hi Uriah,
    sorry if i bother you. This is exactly what we do in XAF: XAF restores the ActiveFilterCriteria with all references, and afterwards we call GuessAutoFilterRowValuesFromFilter - so i ask again why in this case the Filter gets corrupted?
    gridView1.ActiveFilterCriteria = new BinaryOperator("CategoryID!", gridView1.GetRowCellValue(1, gridColumn1));
    gridView1.GuessAutoFilterRowValuesFromFilter();

    DevExpress Support Team 15 years ago

      Hi Martin,
      You are right, for some reason this scenario doesn't work in XAF applications, while in the XtraGrid it works fine. I have to agree with you that the GuessAutoFilterRowValuesFromFilter method should (or, to be more precise, can) correctly restore the filter criteria in any case. I've asked our developers why this method is implemented in this manner. In fact, this method is intended only to restore the Auto Filter after restoring the layout, and shouldn't be used for other tasks (for example, populate the AutoFilterRow, after applying ActiveFilterCriteria). So, we can't consider the current implementation to be incorrect, because this method works correctly in the scenario it meant to be used. I've modified the Subject of the How to restore the Auto Filter Row from the ActiveFilterString, after restoring the layout, because the previous subject has a slightly incorrect meaning.
      Thanks,
      Uriah.

      M M
      Martin Praxmarer - DevExpress MVP 15 years ago

        Hi Uriah,
        i try it the last time. This issue is not related to XAF - what if i only work with XtraGrid and build my own way to store the criteria.
        You have also changed the Subject of the example now wich is wrong in my opinion. The Methods Name is GuessAutoFilterRowValuesFromFilter -> it has nothing todo with restoring the layout - i can call this method also if i build the columns/layout in my own way. So can you please cleary explain why you dont use this constructor:
        ColumnFilterInfo(ColumnFilterType type, object _value, CriteriaOperator filter, string displayText)

        Answers

        created 15 years ago

        Hi Martin,
        The GuessAutoFilterRowValuesFromFilter method is implemented in this way, because it was created to implement a feature requested in the Display the filter in the AutoFilterRow after the view's layout has been restored suggestion. We don't want to break the functionality of existing applications when this feature is introduced, and we want to avoid involving the redundant XtraGrid functionality in this process. This method isn't used for other purposes in our code, and is marked as internal in the documentation: GridView.GuessAutoFilterRowValuesFromFilter Method. We don't consider this implementation incorrect.
        >> what if i only work with XtraGrid and build my own way to store the criteria
        The XtraGrid doesn't provide methods to restore values in the Auto Filter Row from the ActiveFilterCriteria. Even the GuessAutoFilterRowValuesFromFilter doesn't work impeccable in all situations. That is why this feature is still not supported officially.
        Besides the Auto Filter Row, the GridView supports other scenarios of applying the filter. A column filter can be applied via the column's filter drop-down list. In addition, a more complex filter can be applied via the built-in Filter Editor, or via an external FilterControl. The ActiveFilterCriteria can be modified in code. A correct way to restore values in the Auto Filter Row is to save the ColumnFilterInfo of GridColumns, rather that the GridView.ActiveFilterCriteria property.
        Thanks,
        Uriah.

          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.