3.4.1 Form

Source: Internet
Author: User

    1. Goal
    • Identify the main clip to dress up the form
    • Add a data source to a form to define what data the form displays
    • Add a control to a form to display the data
    • Modify the form method to control its behavior when turned on and off
    • Decide where to put the code
    • Modify the acquired data at run time
    1. Introduced

Undergraduate offers comprehensive features that use forms to interact with end users.

Discuss the topic:

    • Form schemas
    • Get Data
    • Placing the code in the hull
    • State-of-the-art controls
    • Special forms
    1. Scene

System developer, to create a new form that has multiple data sources linked together, one field is calculated from another field, the field is not linked to the data source, and the field is initialized when the form is opened. It also investigates other types of forms and form controls.

    1. Architecture

A form provides interaction between the user and the database. It focuses on the following actions:

    • Displaying and receiving data
    • Filtering data
    • Sort data
    • modifying data

The application and business logic are not integrated into the form, but are programmed on the underlying tables and classes.

In the AOT, a form is composed of five components:

    • Method
    • Data source
    • Part
    • Design
    • Permissions

This lesson details three main nodes: methods, data sources, and designs.

    1. Method

A system generation method, which is a system method, a standard method, or an object method, attached to a form to control the startup and closing of a form. These times are overwritten sequentially to initialize the form. By default, system methods are not displayed. To override a system method, right-click the method node, select Override method, and select the method to overwrite.

Alternatively, you can add a method and call it anywhere on the form. This is a good practice to add a method here rather than writing a lot of code in the form design object, which makes the native code more concise.

A variable is defined in a class declaration and can be accessed in all form methods to hold the state of a form control.

The following is a method of the CustTable form. Form system methods Task,run,init and close have been overwritten. All other methods have been added to the methods node.

    1. Data source

A data source defines an interface between a form and a database. An entity is added as each table. The properties of each data source indicate the relationship between the data sources. Each data source also has a system method that can be overridden to control the display of data or manipulation events.

The data source contains all the fields in the table. Again, all fields have properties and system methods can be overwritten. These methods control the following functions:

    • field specifies navigation (filter, find, jump to Main table)
    • Validation fields
    • modifying fields
    1. Design

The design of a form definition is the interface of the form and the user, which controls the layout and data representation. The design consists of the called control components. Some controls are used to edit and display data, and others to control the layout of the form.

The general design of a form is as follows

Design

Tab

TabPage

Grid

Fields to is displayed on Grid

TabPage

Field Groups

Fields in Field Group

All controls on the design have properties and methods, and can be overridden

Under the design node, as with the design node, there is also a design list node.

    1. Working with objects in a form

When programming in a form, you can reference object entities, such as data sources or form controls, use the kernel class to build them, or override the object's own methods.

All methods in a form are associated to an object. The object can use this, which is accessed from the method associated with it. Note This reference is associated to all of your programming.

When an object is referenced from a method and there is no associated object, you need to use object handling. Here are the objects and how to access them

Object

Access from X + +

FormRun

Element

Formdatasource

<name of data source>_ds

Active record in data source

<name of data source>

Formdataobject

Formdatasource.object (<fieldId>)

formdesign

Formrun.design ()

Form ... Control

is assigned to the control's name when AutoDeclaration is set to Yes. or Element.control (Control::<name of control>)

Query

<name of data source>_q or formdatasource.query ()

Queryrun

<name of Data source>_qr or Formdatasource.queryrun ()

4 Data sources

Tables in the data source can be sorted or filtered by the user, which is an important feature of AX.

A form can contain any number of data sources, and each data source can be linked to other data sources on the form by defining the relationships between the tables. A relationship or dynalinks can also be added to the form code.

A form data source produces a query that can be executed in the same way as any other query in the system.

4.1 Joins

To display records from two tables in a form, specify a connection between the two tables.

Specify the connection on the second table or on the Joinsource property of the connected table. Fill in the name of the main data source here.

You can also specify a join or link type. The link type is described later.

The CustInvoiceJour form uses a connection. The Custinvoicetrans data source is connected to the CustInvoiceJour data source, and the InventDim data source is connected to the Custinvoicetrans data source.

InventDim is connected to Custinvoicetrans, using innerjoin because the data is displayed in the same fgrid as the Custinvoicetrans record.

4.2 Referencing a data source

A reference data source, which is a data source that is linked to the parent data source.-recid Relationships through surrogate key relationships.

To add the Surrogate key field from the data source to the form design, the reference data source is automatically created,

4.3 modifying from x + +

Use the Query object to modify the query in the form's data source. The query object can be obtained using <name of data source>_q or Formdatasource.query ().

To make a permanent modification to a query, this typical implementation is called Super () in Formdatasource.init ().

To filter records in a form, you need to follow these steps:

    1. In a class declaration, declare the associated queryBuildRange or QueryFilter object.
    2. In Formdatasource.init, instantiate a Range object.
    3. In Formdatasource.executequery, the actual value of the range is assigned before super () is called.

Perform data sorting by adding a sort field, or by adding an index to the data source for the query. As an alternative, set an index on the properties of the data source.

Using some aggregate field binding ordering will cause the data source to display aggregated information in the table, rather than transaction information. Perform the following steps to display the total number of inventory transactions for each product ID.

    1. On the data source, use Addgroupbyfield to group by item ID.
    2. Add sum (Qty), as Selectionfield

4.4 Public methods to overwrite

4.4.1 Formdatasource.init

The method initializes the data source and is called by the Formrun.init Super () method. When the form is opened, the method is called only once.

The main task of this method is to instantiate the query to get the data.

To modify or replace a query that is automatically created by the form, add an action after the method's super () method.

4.4.2 Formdatasource.initvalue

This method is used to initialize a new record with a default value. The super () of the method calls the InitValue () method of the underlying table.

If you want to modify the system-wide, put the code on the table.

4.4.3 formdatasource.active

This event is called when a new record in the data source becomes active. This method is typically overridden to change the properties of the content that depends on the current record, which, in general, will:

Modify permissions for a data source

Modify permissions for a field

Enable/Disable button

4.4.4 formdatasource.linkactive

The method is called by the joined data source each time the active record changes in the main data element. This method is also called when the bottom of the bed is opened as a system layer and joined to the main data source of the called form.

4.4.5 Formdatasource.validatewrite

This method verifies the insertion or update of a record. The super () of the method calls the appropriate method on the underlying table.

If you want to distinguish between insertions and deletions, make a condition on the RecId field, and if it is update, it has only one value.

4.4.6 Formdatasource.write

This method controls the insertion and deletion of records. The super () of the method calls the appropriate method on the underlying table.

If you have a form special task to perform, add it here.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.