CanSearch Event

Description

This Event fires when a search is initiated. You can cancel the search using this event.

Discussion

This event fires after the user has clicked Submit to submit the Search part, but before the search is executed. The event can check the search criteria submitted and, if necessary, cancel the search by setting the e.cancel property to .t..

The following variables are available to you in the event:

Variable
Description
e.tmpl

The grid component definition

e.SearchDataSubmitted

The search criteria that was submitted

Your event can set the following property values.

Property
Description
e.cancel

Used to cancel the search. To cancel the Search, set e.cancel to .t.. If not set or value is set to .f., the search will be executed.

The e object also contains a pointer to the AjaxResponses array, which can be used to send Javascript to the client. For example:

if e.searchDataSubmitted.Company = "" then
    e.cancel = .t.
    dim aa as p
    aa = e.rtc.A_AjaxResponses
    i = aa.append()
    aa[i].text = "alert('Search was cancelled because you did not specify a value for the Company field.');"
    aa[i].id = 100  'the order in which the Ajax responses are sent to the browser
end if

Setting State Variables 

You can also set state variables in this event. The value of any state variables will be available in all subsequent ajax callbacks (in the e.__si2 object).

To set a state variable:

e._state.myvar1 = "value1"
e._state.myvar2 = "value2"