Unit

The unit control allows you to show a unit from a data source

Brixxbox allows you to have a unit property for each numeric box control. It is a character based property. User can set any character and it will be displayed as a unit with this numeric control. The is one way of assigning unit to a control. Brixxbox also provides it users with a unit control. The only purpose of this control is to load unit from a data source In this way, Brixxbox allow users to store numeric quantities with their units also. For example, this control can be placed as a child control to a numbox control.

Documentation

In Brixxbox, app configuration allows you to add different controls in your app. It also provides four types of properties which manages how control should behave or look in app. Those four property types are:

  1. General Properties

  2. Size

  3. Style

  4. Translation

General Properties


These are the main properties of any control. These properties define how control behaves in Brixxbox App.

  • Control Type

- For using grid control, click on "Add Control" and select "Unit" control type from drop down list.

  • Control Id

- For each Brixxbox app, this id should be unique. For Example: "_abcdef". Brixxbox allows you to change its value only once. You can change this id to any value but it should be meaningful. Recommended way is to start with mandatory prefix(set in app). It can contain numbers, underscores, uppercase and lowercase letters.

  • Label

- It is the display value for control.

  • Refers to Config

- You need to set this option if this is a field, that other fields refer to, to get data from another config.

Tutorial

In this tutorial, we will be using "unitDemo" app. This is very simple app. It's purpose is to elaborate different ways to set unit of different controls. In this app, we have two controls and both of them are numeric. The first field is Item Id, it will be used to store id's of items and second field will be used to store the price of corresponding item. Our app looks like this

As you can see our "Sales Price" is numeric but we do not have any unit with it. Brixxbox provides us with unit property with some controls like "numbox". In this property we can assign any character to make it a unit of specific control. Now, we need to open "Sales Price" properties and update unit to "Euro" and then save the app. Now we can see in the app editor that on left side of "Sale Price" numbox Euro symbol is being displayed.

This is a nice way to assign unit to a specific control but this is control specific and we do not store in our database. Lets assume we want a unit app so that we list all the units available in our database. This can be done in two steps. First, we need to add an "unit" app which stores the names of all the units in it.

It simply stores the names of units we want in our app. Lets quickly add three units in it: Pc for piece, $ for Us Dollar, and € for Euro currency. In second step, we need to add a combobox named "Unit Type" and assign our unit app as its "sub data source" with id, and unit name as combo box key and field values.

Now as you can see from above snapshot, our unitDemo app has a combo box and now we are also seeing all available units which are present in our unit app because we have made unit app, our combobox sub data source. This is another way to display unit next to numeric field. We have already discussed combobox in our tutorial for combobox. If you you need any help for combobox, please visit this combobox documentation link ComboBox Control Documentation.

Now we proceed to our third way of presenting unit with numeric control. Here "unit" control comes into play. Let suppose we want display the price of item in another control. This can be a different app also but for the sake of simplicity we will add new numeric control in same app. We also make new control, lets call it "sale price test", read only. We want a simple functionality that as soon as the value of "sale price" changes, it will reflect on "sale price test" control also. We can add onChange event on "sale price". This event on value change will get "sale price" value and set it as the value of "sale price test".

Now we also want a unit for this control. For this we need to a unit control in our app and make it a child control of our "sale price test" control. We also need to assign a data source to our unit control. Lets add our "unit app" as a data source. This data source will allow it to query and get a specific data from data source.Our app looks like this

Now we can see that our "Sale Price Test" has a box for unit but it is empty. The reason behind this is that we need to add query to get specific unit from data source. Lets assume we want same unit as selected in our unit type combobox. The query is

Now when we change the value of unit in our unit type combobox, this change also gets reflected in our sale price test unit.

Last updated