Two things I have been asked to provide which I’m not sure are possible…
Thing 1: My client wants their Servoy solution to behave a bit more like Filemaker and have asked whether the field that they are searching can request focus on a new find request. In filemaker, if you go into find, click in field z, type some text and hit new request, the focus is still on field z. Possible?
Thing 2: It seems impossible to switch forms while in find mode. Is it (or do I have to add a “go back to browse mode” action to the beginning of each method fired by a navigation button onaction??
You can create new requests just like filemaker, just create a new record while in find mode. ctrl + n
Thing 2:
I have found it much easier to use globals to enter your find critera, the create a method to preform the find, this allows allot more flexability., depending on what you are trying to accomplish.
I know about the new request, I’m doing that. The question is, can the field you were searching in in request 1 request focus when you do a new search request?
Thing two, I’ve used globals for this before, trouble is I have six main sections, each with up to 100 fields and people are going to be searching on all sorts of fields. Even if I were to use just the most frequently needed searches, it’d be a lot of globals…
The following is an example of how we allow users to perform a Find on any field on a form by:
clicking into the field
clicking a “Find” button
The “Find” button is located on a custom controller that is attached to the form. When the user clicks into a field on the form, the first word in the field is automatically entered as the Find criteria in the global searchField that is located on the controller (the user can alter the find criteria as needed). The controller also has a label above the Find button with the words “Click into a field”. When the user clicks into a field the wording on the label changes to display the currently selected field’s name.
The following global get_element_name method is attached to the onFocusGained property of each field on the form. Each form field MUST be given a property name (we give each field a property name that is exactly the same as its dataProvider name).
//when user clicks into field the field's property name is saved to gElementName
globals.gElementName = application.getMethodTriggerElementname();
//the field name is displayed in a searchSelection label above the Find button
globals.searchSelection = globals.gElementName;
//the first word in the clicked field is assigned to the searchField
var fieldname = globals.gElementName;
var fieldvalue = currentcontroller.getDataProviderValue(fieldname);
var fieldLeftWord = utils.stringLeftWords(fieldvalue, 1 );
fieldLeftWord = utils.stringTrim(fieldLeftWord);
globals.searchField = fieldLeftWord;
The following performSearch method is attached to the onAction property of a search button on the custom controller.
//the form's searchField method is called
forms.my_form.searchField();
//focus is returned to the searchField on the custom controller
forms.custom_contoller_name.elements.searchField.requestFocus(false);
The searchField is a form method as follows (the searchSelection below is just a message that appears on a label on the custom controller).
if(globals.gElementName)
{
var searchCriteria = "#%" + globals.searchField + "%"
var fieldname = globals.gElementName;
controller.find()
var dataproviderName = elements[fieldname].getDataProviderID()
controller.setDataProviderValue(dataproviderName, searchCriteria )
controller.search()
}
globals.gElementName = null
globals.searchSelection = "Click in a field"
globals.searchField = null