We are using a lot of Fields with displayType TYPE_AHEAD and a valuelist that uses a global method. Refreshing of the valuelist (calling the global method) is done by Servoy, for instance when a character is typed into the field. Works like a charm.
When the valuelist is dependend on things outside this field we have a problem. For instance: we have project-valuelist that uses global method getDataSetForProject and we have two fields on a form: a TYPE_AHEAD field project_id and a CHECK field is_running. Field is_running has a global variable as dataProvider, this global variable is used in getDataSetForProject.
Now when we check or uncheck the is_running field we want the global method to be fired. This is not done automatically because Servoy does not know something has changed, so also when entering the project-field this does not cause the global method to be fired. As a work-around we created a reload method that we call in the onDataChange of the is_running-field:
function onDataChangeIsRunning() {
reloadValueList(controller.getName(), 'project_id')
}
function reloadValueList(_form_name, _element_name) {
var _element = forms[_form_name].elements[_element_name]
var _data_provider_id = _element.getDataProviderID()
var _old_value = forms[_form_name][_data_provider_id]
forms[_form_name][_data_provider_id] = globals.reload_value_list_counter--
forms[_form_name][_data_provider_id] = _old_value
}
The trick is to set the value of project_id to a value it has never had before and then change it back again, in this way servoy thinks it has changed and will fire the getDataSetForProject-method. This works for Servoy 5 smart client and webclient and for Servoy 7 smart client but not for Servoy 7 webclient in all cases (when _old_value is null). Could anyone think of a solution for this or has another/better work-around?
There is an old feature request for this Jira but apparently it is not important enough to Servoy or did not receive enough votes yet (please vote!)