
A short tutorial demonstrating basic data binding concepts.
The process of data binding in BrightBuilder is aimed at firstly defining the data set of records to which a particular form’s expressions and controls will utilise, and then from this point, specifying how the values in this set may be displayed or modified through the application.
If you have encountered listviews, both features of BrightBuilder work similarly to retrieve records, however a listview results in a specific representation of data, as it is restricted to a list-based view. With data binding, application developers may create many different ways of representing the data using all types of controls.
Use the Data Binding tab to start using data binding in a form. Similar to the listview, the set of records to be utilised needs to be specified by a query to the database. The set of records retrieved will match the Conditions of the query, and the data columns will match Output Fields of the query. Set this query using the drop down menu ‘Form Query’, which lists all queries defined in the project.
When a form query is selected, the data binding tab will change, by enabling the option to use cursor forms, and by populating the ‘Save Data to Table Columns’ table with the query’s output fields.
These aspects are featured when creating cursor forms, which are not covered in this tutorial.
The data source tree will now also contain values in the Form > Data folder matching the assigned query’s output fields.
Also note that if the query contains a parameterised condition, this parameter should also be accessible via the Form > Parameters folder in the tree. Furthermore, if the form to which the query is bound to is a child form opening from a parent form’s control, the parameter should also appear in the ‘Action-Click’ dialog the respective control. This parameter should be assigned a value to load when the child opens.
The data values of the records returned may be accessed and be assigned to controls, or used in expressions through the Forms > Data folder in the data source tree. The values of these data sources themselves may be edited, but this will not update entries in the database. To do this, standard database operations are necessary. Therefore they should be treated as a container, similar to a variable or a control.
The exception to this model is if the form is a cursor form, and the save feature is checked. In this case, any changes to the Form > Data variables will result in a database operation, using the built in functionality of cursor forms. For more information, refer to Data Binding > Saving Data to Table Columns in the Bright Software User Manual.
We may want to load values in the database into controls when the form opens, and this can be done using an expression linked to the ‘Action – Open’ property of a form, such as the one seen in the previous section. However, this process may be made simpler, using BrightBuilder’s ‘Load UI Elements’ feature, which maps controls to data sources.
This also becomes useful when specifying saving data in cursor forms within a project – through the populate button. For more information, refer to Data Binding > Saving Data to Table Columns in the Bright Software User Manual.
This load definition
is similar to:
id_field = ID
loc_field = LOCATION
name_field = NAME
More complex load operations may also be modularised as expressions may also be linked as a source to load from. In this case, the form will run this expression instead of mapping the data source, and this expression will run when the form opens. To select an expression, click on the […] button, and select the ‘Select an Expression’ radio button, then choose one of the form’s expressions.
In the ‘Detail’ form, use data binding with qItemFilter to load the ID, NAME, PICTURE, QTY and LOCATION output of the parameterised query into the id_field, name_field, sketch_field, qty_field and loc_field controls respectively. Set the parameter for this query in the ‘Main’ form.
Complete the onLoad expression, which constructs a local summary string for the item, provided the values of the NAME, QTY and LOCATION fields are not equal to NULL. Have this string load into the summary_field control.
A completed solution is available in BindingFinished.bsp.