GET Cross-platform mobile application development in Delphi # 5 / Sudo Null IT News FREE

Development of cross-platform mobile applications in DelphiPart # 1
Part # 2
Part # 3
Part # 4

In the previous partially of the series, we became more acquainted with with the practical principles of the mechanics for linking LiveBinding objects based on expressions. Thanks to the capabilities of the Visual LiveBinding subsystem, the developer eliminates the need to program these expressions manually. Today we volition continue to develop our application and get acquainted with new techniques for functioning with databases in FireMonkey victimisation FireDAC and LiveBinding.

In the data faculty (DataModule) we will create another data set using the TFDTable constituent . Associate it with the tblIngredientes table . Let's call information technology FDTIngredientes. Aside doctrine of analogy with the previous data sets, create a list of Fields. Make changes to the ConnectToDB procedure.

                                                                      procedure                                                                                            TDM                                            .                                                ConnectToDB                                            :                        Boolean;                          begin                                      try                        FDConnection1.Connected := True;                          // Устанавливаем соединение                        FDTRecipe.Outdoors;                          // Открываем таблицу рецептов                        FDTUnits.Open;                          // Открываем единиц измерения                        FDTFoodstuff.Open;                          // Открываем продуктов                        FDTIngredientes.Open;                          // Открываем ингредиентов                                      except                                      // Обработчик исключений....                                      end            ;   Result := FDConnection1.Connected;                          end            ;                  

According to the logic of the application, we need to make a point that when twisting finished the list of recipes on the main form, the list of ingredients is updated. For each recipe, its list of ingredients should be displayed on the Ingredients tab. It is easiest to implement such functionality victimisation the Master-Details mechanism at the grade of factor relationships.

First off, you must set the MasterSource property for the subordinate information settled (FDTIngredientes). For communication, we leave have to use the TDataSource ingredient. "Stick" it to the FDTRecipe component, which is responsible for outputting data from the tblRecipe table, and call it dsRecipe. MasterSource propertycomponent FDTIngredientes set (select from the drop-downwards list) the value dsRecipe. Using the attribute editor, put off the value of the MasterField property - Id. And finally, we will select the prise of the IndexName material possession - idxRecipe from the list of indexes . The data index indexes the tblIngredientes table past the IdCB field, which is responsible for linking to the recipe table.

Firedac

In fact, at the level of data access components, everything works the same as in VCL.

On the main form of the lotion, attend the "Ingredients" tab and call LiveBindings Couturier . Place happening the tab TGrid and TBindNavigator, and "constipate" these components to FDTIngredientes, as we did in the last part by "dragging" or "drawing links" happening the visual diagram. Now, if you run the application, then, in all likelihood, the system of logic of displaying the ingredients at this stage will seem uncomprehensible to you. Indeed, the grid displays not the names of products, and units of measure, but their codes (Id).

Now we need to right display the values ​​of ware names and units of measure in the formula. For this we use the so-called " Search " - fields ("viewing" fields). Call the tilt of William Claude Dukenfield of the FDTIngredientes component and create a untested field (in the context menu, select New Field ...). Fill in the data in the field editor as shown in the figure:

Lookup field

The Product name will display the public figure of the merchandise from the Food product table whose Id will fit to the value of the IdFs field in the FDTIngredientes table. Pay attention to the value of Field type .

In the homophonic way, make up Lookup to display data from the Units table (units).

firedac field editor

Immediately, we need, firstly, to correctly display the Search values ​​of the Fields in the grid constituent, and also create a data input mechanism.

Let's go back to the main form and stead two TComboBox components on IT (let's cry them cbProd and cbUnit) and ace TEdit, A shown in the figure.

Firemonkey application form

In LiveBindings Room decorator, we consociate the properties of these components with information sources, as shown in the figure:

LiveBindings Designer

The rules for connecting the TComboBox component to the data source are quite lancelike. Item.Text is associated with a field whose values ​​appear in the drop-down number. Item.LookupData is associated with a field whose value is substituted into the editable dataset. Consequently, SelectedValue is associated with the editable field of the editable dataset.

Now configure the Reference grid. By large-clicking along the BindingsList1 component part (the component public figure was assigned mechanically, you can change it), undisguised the link editor and select the TLinkGridToDataSourceBindSourceDB component. In the Object Inspector, call the Columns property editor. Army of the Righteou's create all the fields (Add Every Fields push button) and set the display title of respect and visibility (Visible property) for each of them, kindred to the way we did in the previous start.

Launch the application. When you move through the list of recipes, on the "Ingredients" tabloid, the list of products is updated, which indicates that the Master-Details link is working correctly. We can set the value of the product name and unit of measure in the recipe using the drop-down list (ComboBox). The elect values ​​are displayed correctly in the grid.

In the next part, we will transfer the freshly implemented functionality to the racy chopine.

Until Fri!

DOWNLOAD HERE

GET Cross-platform mobile application development in Delphi # 5 / Sudo Null IT News FREE

Posted by: touchstonethiphrisity.blogspot.com

0 Response to "GET Cross-platform mobile application development in Delphi # 5 / Sudo Null IT News FREE"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel