Creating an app : Adding data sources
  

Adding data sources

To add a data source from an existing Progress Data Provider or OData Provider:
1. Click an appropriate data provider listed on the app design page. This opens the Data Sources page displaying any existing data sources, listed by name.
Note: If you chose the optional Auto-create Data Sources when creating your data provider, new data sources may already be added to this page with some of the work described below already done for you. However, you can manually edit any existing data source and its individual field properties as needed. You can also add custom data sources in addition to the ones automatically created. To manually edit an existing data source, click Edit to the right of the data source name, which opens the Edit Data Source dialog box, then proceed with Step 4.
2. Click + Add Data Source, which opens the Add Data Source dialog box.
3. Enter a Name for the data source.
4. To set (or reset) the table and fields defined for the data source, search for or navigate to the data provider table from which your app will draw data. Click the table name, which displays all of its available fields in the Included fields list along with their semantic types as defined by the data provider.
5. You can use the Include all and Exclude all buttons to move the entire list of fields back and forth between Included Fields and Excluded Fields lists. You can also drag and drop individual fields back and forth between the lists. The order that the fields appear in the Included Fields list is the default order that will be used for grid columns and/or form fields, so drag and drop the included fields into the order you prefer. You can later change the default field order for both the grid columns and form fields of any view that you create.
6. When you select a particular field in the Included Fields list, you can specify the Label and Editor Type properties. The Label is used as the column head and/or the field label in the view at run time. (See the sections on modules and views for more information.) The Editor Type specifies the UI component that presents the field for display or editing at run time. You can select an editor type based on the underlying semantic type for the given field. For example, a date field might offer the option of a text-input editor or a date-input editor (date picker). For more information on semantic types, see Kendo UI Builder by Progress: Modernizing OpenEdge Applications.
Note: Editor types determine how a field is rendered on an editable form for either the Data-Grid-Form view or the Data-Grid-Separate-Form view. You can set optional properties and event functions on the editor type for a given field when you edit the form fields as described for instances of these views. For more information, see Editing form fields.
Note: Enter plain-text as the Editor Type to display a field as read-only on an otherwise editable form. This is useful for auto-generated fields, such as a primary key field whose value is maintained on the server.
7. For a Progress Data Provider only, if the field you select in the Included Fields list is specified with the Lookup semantic type, the field is a foreign key that references a row in another (or even the same) table. A foreign key uniquely identifies a row in the other (parent) table by matching a candidate key in the current data source table to a primary key in the parent data source table. A candidate key is a single field in the current data source whose value must match a single field (parent field) in the parent data source. This parent field must function as a primary key in order to uniquely identify a table row in the parent data source.
Note: Theoretically, a candidate key can represent multiple fields that match corresponding fields of the primary key in the parent. However, this release supports only a single field for the both the candidate and primary keys.
A foreign key can only be used to look up a unique row in a table of a compatible parent data source that is defined in the same data provider as the current data source, and where both the parent and current data sources represent top-level tables in the data provider.
The field name of the foreign key is defined by the data provider and appended with "FK9" by the Designer to ensure uniqueness, where 9 is an integer increment starting at 1 (for example, SalesrepIdFK1). The available Editor Type options for its Lookup semantic type include combo-box (the default), drop-down-list, and plain-text.
When you select a foreign key field, the following additional properties are available to control the behavior of its selected Editor Type at run time:
*Data Source: A selection from a list of data sources all of which contain a table with the same name as Parent Table and fields with the same names and types as Parent Fields. These data sources all share the same data provider as the current data source. The selected data source then represents the parent table for look up using the foreign key.
*Display Field: The field to display from the row that the foreign key identifies in the parent table. If the Editor Type is combo-box or drop-down-list, Display Field displays a list of values for this field from the available rows in the parent table. The user can change the foreign key value by selecting a different value for this field, which returns a new candidate key value from primary key value of the associated parent table row.
*Fields: Read-only list of fields in the current data source table that define the candidate key for the foreign key field.
This release supports candidate keys defined with only a single field from the current data source.
*Parent Table: The read-only name of the parent table, qualified by the name of the remote Data Object resource that contains the table. This is also the name of one of the corresponding data sources created for the current data provider. This qualified parent table name can also be used to name the foreign key, depending on how it is defined by the current data provider.
*Parent Fields: Read-only list of fields in the parent data source table that defines its primary key. These primary key fields correspond in type and number to the Fields that define the candidate key. At run time, they must match the corresponding candidate key fields in order to uniquely identify a record in the parent table.
This release supports primary keys defined with only a single parent field.
8. (Optional) Select Client-side processing to indicate your app will retrieve all data from the data source before the view is visualized and perform data presentation operations (sorting, filtering, and paging operations) on the client side. Otherwise, only a page of data is retrieved from the data source to display in the view on demand, and all these presentation operations are performed on the server side.
Note: If client-side processing is not selected, the data service must support code for processing the request. This is done by enhancing the business logic to include code for filtering, sorting, and paging the data. For an OpenEdge Data Object Service, this is implemented in the Business Entity. Business Entities support a JSON Filter Pattern (JFP) that the Read operation method interprets by executing this code and a count method that provides the total number of records read. (You are prompted to enter the name of this count method if Client-side processing is not selected.) For an example Business Entity implementation that handles the JFP and provides a count method, see "Updates to allow access by Kendo UI DataSources and Rollbase external objects" in OpenEdge Development: Web Services.
To add a data source from an existing Generic REST Provider:
1. Click a Generic REST Provider listed on the app design page. This opens the Data Sources page displaying any existing REST data sources, listed by name.
Note: To edit an existing data source, click Edit to the right of the data source name, which opens the Edit Data Source dialog box, then proceed with Step 4.
2. Click + Add Data Source, which opens the Add Data Source dialog box.
3. Enter a Name for the data source.
4. To define fields for the data source, click Data Source Fields (if necessary ) to display the Fields list and click + Add Field, which inserts a field in the list and enables the Properties for it with default values that you can change as follows:
*Name: Enter a unique name in the list (default: field).
*Label: Enter a label to display for the field at run time (default: Field Label).
*Type: Select a JSON data type for the field (default: string).
*Editor Type: Select an editor type from the list of editors that are compatible with your selected Type (default: text-input). The Editor Type specifies the UI component that presents the field for display or editing at run time. These are the same editor types that are available for the compatible field semantic types defined by other data providers. For more information on editor types, see Kendo UI Builder by Progress: Modernizing OpenEdge Applications.
*Required: Select this check box if the field must be present when the data source is serialized (default: not selected).
Repeat this step for as many fields as you need to define. To delete a field from the data source select its trash icon.
Note: You cannot change the order of these fields by dragging and dropping them in the list. You must define them in the order you want them to appear in the data source. However, you can later adjust the order that any data source fields appear in the grids or forms that you define for them in views.
5. To define the supported data source actions, click Data Source Actions to display an expandable list of these actions, which are identified by the supported actions on a Kendo UI Data Source: Create, Destroy, Read, and Update. To define an action, clicking its expander (+), which displays the following property settings:
*Type: Select the REST verb for the action, with a default initially selected depending on the action. For example, the default verb for the Create action is POST. Select the verb that corresponds to your REST Service definition.
*URL: Enter the URI for the action object relative to the Base URI specified for the data provider.
6. To complete the data source settings, click Data Source Settings, which specifies the following property settings:
*Id Field: Use the drop-down list to select a data source field that functions as a primary key to the data source.
*Data Field: A field in the server response that returns one or more rows to the data source.
*Total Field: A field in the server response that contains the total number of rows returned in the response.
*Client-side processing: Select check box to indicate that your app will retrieve all data from the data source before the view is visualized and perform data presentation operations (sorting, filtering, and paging operations) on the client side. Otherwise, only a page of data is retrieved from the data source to display in the view on demand, and all these presentation operations are performed on the server side. In this case, the data source uses the value returned by Total Field to manage the paging of data on the server.
The data source(s) you have created are now available for use by views in a module.
Note: If you create one or more views using a data source and then come back to change some of the details of that data source, such as labels and editor types, those changes will not be reflected in the views you have already created. These changes are in effect for any new views you create, but cannot be propagated back to views you created prior to making these data source changes.