OnSearchPartFilterCompute Event



A dot variable with the following properties:


The grid component definition


Run-time calculations (allows you to pass data to other event handlers). The e.rtc variable has the following properties:


The filter computed from submitted data in the Search Part


The parameter value for arguments in the filter


Search data submitted.


This event fires after user has clicked Submit to submit the Search part, and after the Search Filter has been computed, but before the Search is executed. It allows you to modify the Search Filter.


The OnSearchPartFilterCompute event can be used to modify the search filter before it is executed. You can modify the value of e.rtc.filter_SearchPart and e.rtc.Parameters_SearchPart

For example:

e.rtc.filter_searchPart = "lastname = :whatLastName"
e.rtc.parameters_searchPart = e.SearchDataSubmitted.Lastname+"|||C|whatLastName"

The .parameters_searchPart variable is only needed if the .filter_SearchPart variable uses arguments. .parameters_searchPart is a CR-LF delimited string with one entry for each argument used in the filter. It is of the form:


Where Type is a one character Xbasic data type (e.g. C,N,E,D,T,S, or L) of the field you are searching.

If your data source is DBF, then your .filter_searchPart must use Xbasic syntax.

If your data source is SQL, then your .filter_searchPart must use SQL syntax.

The OnSearchPartFilterCompute event is often used in conjunction with putting variables into the Search Part form.

To put a variable in the Search Part, configure one of the search fields to use a 'Freeform layout'. In the Freeform template, enter HTML similar to example below which creates a variable called 'myvar1' in the Search Part:

<input id="{grid.componentname}.S.MYVAR1" size="40" maxlength="200" class="GlassOliveInput" type="text" name="S.MYVAR1" value="" />

In your event handler, you can refer to this value in myvar1 as:

dim myvar1 as c = e.searchDataSubmitted.myvar1

Sending Javascript to the Client 

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 Expression was recomputed.');"
    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"