About refreshing collections

The filter specification for a collection can reference a property, component, or variable. WinStudio creates a dependency between the collection and the property, component, or variable referenced in the filter specification. (A dependency is created as long as the filter does not specify a property on the collection itself.) When the value of the property, component, or variable is changed, the dependency triggers a refresh of the collection automatically.

For example, suppose you want the primary collection on a form to be refreshed whenever the user changes the value of a combo box that is bound to a variable. If you reference that variable in the filter of the primary collection, then WinStudio creates a dependency so that the primary collection will be refreshed whenever the variable's value changes. (To reference a variable in the filter of the primary collection, use the  FILTERPERM keyword.)

In cases where one collection should be refreshed because of changes in another collection, you can set up a collection-subcollection relationship. The built-in functionality of subcollections causes them to be refreshed automatically as often as necessary. Whenever possible, use subcollections to handle refreshing multiple collections. Doing so minimizes form complexity and keeps behaviors consistent across your application.

In rare cases, you might need to create a form that works with multiple collections that do not have the straightforward parent-child relationships characteristic of subcollections. In these situations, you can set up a primary collection and one or more secondary collections. To refresh the primary collection based on a changed property in a secondary collection, you can generate a data-changed event on the component bound to that property and then create event handlers of the type Collection Refresh to trigger the refresh of the primary collection.

Rubriques liées