Ticket Q356778
Visible to All Users

How can I activate "case insensitive" search in lookup views ?

created 13 years ago

Hello DevEx team !
Have following problem:
the search in lookupviews is "case sensitive" and it's confused users.
How can i change it to "case insensitive" ?
PS. I use servermode in my project.
Thanks
JeyKey

Comments (2)
Anatol (DevExpress) 13 years ago

    Hello JeyKey,
    It appears that you are using the case-sensitive collation in your database. Make it case-insensitive to achieve the desired behavior.
    Thanks,
    Anatol

    C C
    Crem Solutions Developer 13 years ago

      Hello Anatol!
      thanks for answer , but it's not a solution for me.
      i can't change this in database global.
      If it's possible to do it in DataStoreProvider, can you tell me how .
      Thanks
      JeyKey

      Answers

      created 13 years ago

      Hello JeyKey,
      You can add the Upper or Lower functions to the filter to make it case-insensitive. For example:

      C#
      public class ViewController1 : ViewController { public ViewController1() { TargetViewId = "DomainObject1_LookupListView"; } protected override void OnActivated() { base.OnActivated(); Frame.GetController<FilterController>().CustomBuildCriteria += new EventHandler<CustomBuildCriteriaEventArgs>(ViewController1_CustomBuildCriteria); } void ViewController1_CustomBuildCriteria(object sender, CustomBuildCriteriaEventArgs e) { e.Criteria = CriteriaOperator.Parse("Contains(Upper(Name), ?)", e.SearchText.ToUpper()); e.Handled = true; } protected override void OnDeactivated() { base.OnDeactivated(); Frame.GetController<FilterController>().CustomBuildCriteria -= new EventHandler<CustomBuildCriteriaEventArgs>(ViewController1_CustomBuildCriteria); } }

      Please feel free to contact us if you have any difficulties.
      Thanks,
      Anatol

        Show previous comments (4)
        Anatol (DevExpress) 13 years ago

          Hello JeyKey,
          It appears that the Name property does not exist in the Meldung class, for which ListView is shown. I have provided ViewController1 just as an example. If you wish to use case-insensitive search in all list views, you need to generate the search criteria dynamically based on properties of the shown class. I believe that the root listview FilterByText include the collection propertys Support Center issue will be helpful.
          Thanks,
          Anatol

          C C
          Crem Solutions Developer 13 years ago

            Hello Anatol,
            thank you for advice. Have adapted to my needs, and it's work fine.
            JeyKey

            O O
            Olivier Jacot-Descombes 9 years ago

              I have implemented a solution that automatically works with all the LookupListViews:

              C#
              public class LookupListViewController : ViewController<ListView> { private static readonly string[] _possibleSearchFields = new string[] { "Name", "Description", "Text" }; protected override void OnActivated() { base.OnActivated(); if (View.Id.EndsWith("_LookupListView")) { Frame.GetController<FilterController>().CustomBuildCriteria += ViewController1_CustomBuildCriteria; } } // Implement case-insensitive search in DropDowns. void ViewController1_CustomBuildCriteria(object sender, CustomBuildCriteriaEventArgs e) { List<IModelMember> members = View.Model.ModelClass.OwnMembers .Where(m => m.Type == typeof(string)) .ToList(); foreach (string searchField in _possibleSearchFields) { if (members.Any(m => m.Name == searchField)) { CriteriaOperator op = new FunctionOperator(FunctionOperatorType.Upper, new OperandProperty(searchField)); string searchValue = String.Format("%{0}%", e.SearchText.ToUpperInvariant()); e.Criteria = new BinaryOperator(op, new OperandValue(searchValue), BinaryOperatorType.Like); e.Handled = true; return; } } } protected override void OnDeactivated() { base.OnDeactivated(); if (View.Id.EndsWith("_LookupListView")) { Frame.GetController<FilterController>().CustomBuildCriteria -= ViewController1_CustomBuildCriteria; } } }

              "_possibleSearchFields" lists common property names that you have used in lookup entities. You may have to adapt this list.

              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.