Search rules

Description

Alpha Anywhere contains a number of different options for creating search features.

There is a Search Part, a Quick Search, a Query by Example Search, and an Alphabet button search. The Search rules property specifies which search rules should be applied when performing different types of searches. For example, if a grid allows a Quick Search and an Alphabet button search, if the user does an Alphabet Button search, and then does a Quick Search, should the Alphabet Button search be cleared before the Quick Search is Applied? If not, then the Quick Search will be in addition to the Alphabet Button criteria. While this might sound a bit convoluted it does have some useful applications. For instance, it allows users to search through data that has already been filtered using a separate search feature.

To create new search rules simply click the button [dot_img] to the right of the property. This will open the Search Rules dialog.

images/1_alphabet15.png

Defining Search Rules

images/1_alphabet16.png

Search Rules Explained:

  1. Next to the Query by example search: option the Alphabet button search checkbox is checked.

    images/1_alphabet17.png
  2. When a user does an actual Query by example search on a field using the Starts with (x..) filter, where x equals b, then they will get a list of everything in that field starting with b. 

    images/1_alphabet18.png
  3. Now say that the user also has an Alphabet button Search. They click the 'A' button to list everything starting with 'a' after doing the Query by Example search shown above. The user will receive a ' No records in query ' message. Because the Alphabet button search is checked, the Alphabet button search is now only looking at the part of the field that the Query by example search filters, i.e. the part of the field containing records starting with 'b'. It will therefore not find anything starting with 'a'.

    images/1_alphabet19.png

How to Dynamically Show/Hide the Alphabet Buttons Search Bar

The Alphabet Buttons search bar is a useful addition to your Grid if your Grid is displaying a large number of records, but if there are only a few records in the Grid (perhaps because the last search that was run only returned a few records), you might want to hide the Alphabet Buttons search bar.

The following Javascript can be used to dynamically show/hide the Alphabet Buttons Search Bar:

records = {Grid.object}._totalRecordsInGrid; 
ele = $('{Grid.ComponentName}.ALPHABETBUTTONS');
minRecords = 5; 
if(ele) { 
    if(records < minRecords ) ele.style.display='none' ;
    else ele.style.display = ''; 
}

If there are fewer than 5 records in the Grid, the Alphabet Buttons Search Bar will be hidden.

This code should be added to the 'afterAjaxCallbackComplete' event in the Javascript - System Events category. To learn more, watch the videos below:

Alphabet Button Search - Dynamically Hiding/Showing the Search Bar

The Alphabet Buttons search bar allows you to quickly search for records in a Grid that start with a certain letter. In the case of a Grid with just a few records, you might want to hide the search bar. This video shows how you can use Javascript System Events to dynamically show/hide the search bar.

See Also