Ticket Q343797
Visible to All Users

Full Text Search - Include collection properties

created 14 years ago

Hello,
in the root listview, the filterbytext only filter the property of root listview, but I want it filter include the collection propertys(nested listview),
what should I do?
can you provide a general method?
thanks,
XinRong Liu

Comments (2)
Anatol (DevExpress) 14 years ago

    Hello Liu,
    To accomplish this task, subscribe to the FilterController.CustomBuildCriteria event and pass the criteria that includes properties of the associated collection. To filter by the nested collection's properties, use the ContainsOperator.
    Thanks,
    Anatol

      Hello,
      Please see the attched E231 sample preject, I have modified the project for this issue, I hope to filter the OrderHeader when Orderline in either one of the field contains the "beer",then display the filtered OrderHeader listview.
      Note:I need a general method to resolve After that all similar problems And don't like E231 that to the designated need fields.
      Can you help me?
      Thanks
      XinRong Liu

      Answers

      created 14 years ago (modified 6 years ago)

      Hello Liu,

      Update
      Consider using a newer approach from the following ticket: Filtering - How to search in collection properties using the FullTextFilter Action.

      I have found that my initial suggestion was not optimal because it is required to build criteria for the root class manually with it. To avoid this, you can patch the ListView's filter after it is set via FullTextFilterAction, as shown below:

      Visual Basic
      Partial Public Class MyFilterController Inherits ViewController(Of ListView) Public Sub New() InitializeComponent() RegisterActions(components) End Sub Private Sub MyFilterController_Activated(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Activated Dim standardFilterController As FilterController = Frame.GetController(Of FilterController)() If standardFilterController IsNot Nothing Then AddHandler standardFilterController.FullTextFilterAction.Execute , AddressOf FullTextFilterAction_Execute End If End Sub Private Sub FullTextFilterAction_Execute(ByVal sender As Object, ByVal e As ParametrizedActionExecuteEventArgs) If Not String.IsNullOrEmpty(TryCast(e.ParameterCurrentValue, String)) andalso View.CollectionSource.Criteria.ContainsKey(FilterController.FullTextSearchCriteriaName) Then View.CollectionSource.Criteria(FilterController.FullTextSearchCriteriaName) = GetCriteriaOperator(e.ParameterCurrentValue, View.CollectionSource.Criteria(FilterController.FullTextSearchCriteriaName)) End If End Sub Private Function GetCriteriaOperator(ByVal searchValue As Object, ByVal initialCriteria As CriteriaOperator) As CriteriaOperator Dim result As new GroupOperator(GroupOperatorType.Or, initialCriteria) result.Operands.Add(New ContainsOperator("OrderLine", New BinaryOperator("GoodsName", searchValue))) Return result End Function End Class

      To build additional criteria automatically based on class properties, use type info, available via the View.ObjectTypeInfo property. The code of the FilterController.GetFullTextSearchProperties method from our sources may be helpful.

        Show previous comments (1)
        Anatol (DevExpress) 14 years ago

          Hello Liu,
          I have implemented the functionality you have requested. Here is the result:

          Visual Basic
          Private Sub FullTextFilterAction_Execute(ByVal sender As Object, ByVal e As ParametrizedActionExecuteEventArgs) If Not String.IsNullOrEmpty(TryCast(e.ParameterCurrentValue, String)) AndAlso View.CollectionSource.Criteria.ContainsKey(FilterController.FullTextSearchCriteriaName) Then View.CollectionSource.Criteria(FilterController.FullTextSearchCriteriaName) = ChangeCriteriaOperator(TryCast(e.ParameterCurrentValue, String), View.CollectionSource.Criteria(FilterController.FullTextSearchCriteriaName)) End If End Sub Private Function ChangeCriteriaOperator(ByVal searchText As String, ByVal initialCriteria As CriteriaOperator) As CriteriaOperator Dim result As New GroupOperator(GroupOperatorType.Or, initialCriteria) for each memberInfo As IMemberInfo In View.ObjectTypeInfo.Members If memberInfo.IsList Then result.Operands.Add(New ContainsOperator(memberInfo.Name, GetCriteriaOperator(searchText, memberInfo.ListElementTypeInfo))) End If Next Return result End Function Public Function GetCriteriaOperator(ByVal searchText As String, ByVal typeInfo As ITypeInfo) As CriteriaOperator Dim criteriaBuilder As New SearchCriteriaBuilder(typeInfo) criteriaBuilder.IncludeNonPersistentMembers = False criteriaBuilder.FillSearchProperties() criteriaBuilder.SearchText = searchText Return criteriaBuilder.BuildCriteria() End Function

          As you can see, the GetCriteriaOperator methods use the SearchCriteriaBuilder class, as the FilterController.GetFullTextSearchProperties method does.
          Thanks,
          Anatol

            Hello Anatol,
            Thank your great work, it is work fine!
            thank you very much again!
            Xinrong Liu

            Anatol (DevExpress) 14 years ago

              You are welcome!
              Thanks,
              Anatol

              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.