Using Button Binding with Brazos UI

Follow

A common question with Brazos buttons is what types of data can you bind to them and in what context. Brazos buttons take a variable type “ANY” meaning that you can bind any type of data to them, however, there are only two contexts in which binding data to these buttons is actually useful. Both of these contexts are when you use the Brazos buttons inside a Brazos table to either track the selected table index or the selected row object. If tracking which button on a coach is clicked is desired, that can be accomplished via configuration options rather than binding.

Tracking the last selected table index

If you use a button in a Brazos data table, you can create a variable of type integer and bind this variable to the button to track the last table index that was clicked.

1. Below we have created a “rowSelected” integer variable and bound it to the button within the table.

2. Now you can see below that when we click the button on the second row (index 1 of the table), this will select the row and our output field text displays the index of the last button that was clicked.

 

Binding the last selected row’s business object

1. Similarly, we can bind the entire business object of the last selected index of the table. Below we have created the variable “tableIndexObject” and bound it to the button.

2. Now if we open the coach, we can see that the business object of the last selected row are output when the respective button is clicked.

3. If we select another row, the data is updated.

 

Using Button Control ID rather than Binding

Determining which button is clicked on a coach can be accomplished outside of using distinct boundary events and scripts for each button by using the Button Control ID configuration option.

1. Below we have created a variable “lastButtonClicked” and also created four different buttons. Now we set the Button Control ID for each of these buttons to the “lastButtonClicked” variable. Note we have not bound any variables to these buttons as we did in the previous example.

2. Now when any of these buttons are clicked, we can trigger a script to update variables and/or data based on the last button that was clicked.

3. When the first button is clicked, the lastButtonClicked variable is updated via the script and displayed in the output text.

4. When the second button is clicked, the lastButtonClicked variable is updated via the script and displayed in the output text.

Have more questions? Submit a request

Comments

Powered by Zendesk