Parameter | Description |
---|---|
sSearchText | Text to serch for |
Procedure OnSearch String sSearchText
This is called by the client's JavaScript engine to perform a search on an automatic data-aware list (peDbGridType = gtAutomatic and pbDataAware = True).
It performs a lookup search on the passed value based on the current sort column (piSortColumn). It does this by sending RequestColumnLookup to the appropriate column object, which will find the target record and refresh the list.
You can augment this function to modify how a lookup search is performed.
Note that the value passed in the sSearchText parameter will be in a generic format appropriate for transport to and from a client browser. If the column being searched is a Date, DateTime or Numeric data type (e.g. peDataType = typeDate), then you will need to convert the value from its generic transport format to the local format for that type used by your DataFlex server application.
For example, a date type value will be passed to this function as yyyy-mm-dd. If your server is based on the USA date format then it will need to be converted to mm-dd-yyyy. You would use the framework's ConvertFromClient function to perform this conversion.
The sample code below demonstrates how to augment OnSearch and correctly convert the sSearchText parameter based on the target column object's data type.
Procedure OnSearch String sSearchText Integer iCol Integer eType Handle hoCol // Get the target search column's id WebGet piSortColumn to iCol If (iCol >= 0) Begin // get the search columns object handle Get GetColumnObject iCol to hoCol // Get the column object's data type. WebGet peDataType of hoCol to eType // perform format conversion (e.g. dates or numbers) Move (ConvertFromClient(eType, sSearchText)) to sSearchText // Perform the lookup Send RequestColumnLookup of hoCol sSearchText End End_Procedure