Using Increment Searching

[Article by Brice VIDAL]

Incremental searching is a way to search records according to different criteria without having to redefine the SQL property of your IB_Query nor having to unprepare, prepare and execute your query each time a new key is pressed. A good illustration of Incremental Searching can be found in the Contact sample.

Setting up the Incremental Search
You need to define your search criteria by tuning the following properties:

OrderingItems:This property defines the fields that can be used for the sort. The syntax is simple: "field". If you want to display an appealing name in the order dialog box (see below) use the syntax "Name=field". You might be willing to use a descending sort, for this use the same syntax as above and add : "; field DESC". If you only want to be able to do a descending sort, use the syntax "field DESC".  
OrderingItemNo:Reference to determine which entry in the OrderingItems property will be used for the sort order.  
OrderingLinks:Enables a glyph in the header of the columns (of grids) that tells if the column is used for the sort and which type of sort is applied. The syntax is "field=numrical reference in the OrderingItems" (1 corresponding to the first item).  

Using the Incremental Search
The most common way to use an incremental search starts with setting up some IB_Edit to map the fields you want to be able to use for the sort or display. Then you need an IB_NavigationBar to be able to browse in the records. The only required setup is the DataSource property. Finally you have to use an IB_SearchBar  without forgetting to choose a DataSource.

When you want to change the sort order just click on the order button of the IB_SearchBar (the open book with the red arrow) and then the list that you defined in the OrderingItems appears.

To enter the search mode, click on the search button of the IB_SearchBar (the open book with a question mark). Then type in the fields that you want to use for the sort the value that they should have. Finally click on the next button of the IB_NavigationBar and now you are browsing the records that match your query. If you want to know how many rows their are, just click on the count button of the IB_SearchBar (the open book with a sigma).

The same can be done with an IB_Cursor if you wish. The IB_Cursor component is a single-buffer unidirectional dataset ideal for scanning through records one at a time in sequential order. It uses very little memory and is the fastest way to do a full table scan. The IB_Query component is a buffered scrollable dataset that is ideal for browsing by users and providing a randomly scrollable dataset. It requires that its KeyLinks property be defined in such a way that each row of output data can be uniquely defined.

Other possible use of the Incremental Searching
This use works only if you use an IB_Query. Here to you have to set it correctly especially for the OrderingLinks property. You no longer need the IB_NavigationBar and the IB_SearchBar but you will need an IB_Grid to display the data. The difference with the first method is that you no longer need the IB_Edit components. Instead you use one IB_IncSearch. To setup your IB_IncSearch you only need to select a DataSource property.

Next when you want to search a value in a field just click on the header of the column field. As this will select the field to search on you can only search one field at a time. Clicking on the header will also allow you to sort the fields. Once you have clicked on a field, enter the value you want to find in the IB_IncSearch field and click on Return, you automatically get to the first field in the grid that corresponds to your search criteria.