Tables Tutorial

 

Documentation home

Introduction. 1

Instructions 1

 

See also:       Tutorial – Building your First Form,

Tutorial – Building a Form with Database Integration,

Tutorial – Using XML and Web Services,

Tutorial - Display and update of table with foreign keys,

Tables,

Controls, Form Editor 

 

Introduction

 

In this tutorial we will create a form containing a table. We assume that you have some familiarity with using the Ebase Designer. If not, you are recommended to start with the tutorial Building your First Form.

 

We will build a small application for maintaining a CD collection. It will support the following functions:

 

 

This application will make use of the following database tables which are included in the Ebase Samples Database:

 

  • mycds

this is the main CDs table

  • cd_classifications

main classifications e.g. Popular, Classical, Jazz etc

  • cd_sub_classifications

sub classifications within the main classification

 

Note: These three tables already exist in the database ebase_samples provided with Ebase. If you need to create the ebase_samples database yourself scripts can be found here: <Ebase_Installation_directory>\UfsServer\databaseSchemas

 

Instructions

 

Check Designer Preferences

 

Open the Designer Preferences Dialog by selecting File --> Preferences from the menu and click the Page Editor tab. At the bottom of the page, check both Page Panel Control and Page Navigation Panel Control. This ensures that these two controls are added to all new pages. This can be reversed at the end of this exercise, if required.

 

Import the database tables

 

 

Build the classification dynamic list

 

This list will be used to classify a CD.

 

 

Build the sub-classification dynamic list

 

This list will be used to further classify a CD.

 

 

Create a business view

 

 

Create the USER project

 

 

Create the form and set up table display

 

 

In the Outline View, you can see that this has created a Table Control, a Table Page Control and a number of Table Column Controls. The Table Control represents a visible table, a Table Page Control represents a horizontal scroll page within this table, and the Table Column Controls represent columns.

 

 

 

 

Hint: initially, these properties are taken from default values configured in the Presentation Template associated with the form.

 

·         Click on the Toggle designer view icon  on the WYSIWYG View toolbar – this shows the page as it will actually appear in the browser. Before this, the page display was operating in assisted mode where the system makes some small changes to make the design process easier. We can see that the table is too wide and overflows the page – this is because the lengths for the individual columns are too large and exceed the percentage width specifications we have assigned. Maximise the WYSIWYG View by double clicking on the Title Bar – this contains text Page PAGE_1 on a light blue background. There still isn’t enough space to display the table. Double click the WYSIWYG Title Bar again to return to normal.

 

·         To correct this problem, select the table columns in the Tables View one by one, and change the Display Length property (Presentation section) as follows:

 

Column

Display length

CDS-ARTIST

25

CDS-TITLE

40

CDS-COMPOSER

15

CDS-CLASSIFICATION

10

CDS-SUB_CLASSIFICATION

10

CDS-RATING

1

 

 

·         Click on the Toggle designer view icon  on the WYSIWYG View toolbar again to return to the assisted display.

 

 

Add database integration

 

Add an FPL script to load the table from database:

 

 

Add an update table button and an FPL script to perform the updates:

 

 

Add a sequence to number the CDs as we enter them:

 

 

Add a script to use the sequence

 

FPL:

Javascript:

 

sequence CDS;

set CDS-CD_ID = $NEXT_SEQUENCE_ID;

 

var next = system.sequenceManager.sequence("CDS");

tables.CDS.CD_ID.value = next;

 

 

 

Set up the classification lists

 

  1. Classification – this is a simple list that shows a list of main classifications

In the Tables View select the CDS-CLASSIFICATION column and change the following properties in the Properties View

  1. Sub-classification – this list is more complicated: it shows a list of sub-classifications within the main classification. The list is re-built each time the main classification list is changed.

Select the CDS-SUB_CLASSIFICATION column and change the following properties in the Properties View

 

 

Run the form

 

 

Final touches

 

 

 

Optional Further Enhancements

 

Adding a reviews button column

 

We'd like to be able to add a button on each row which, when clicked, takes us to another page which allows the user to enter a review of the CD. This could be done as follows:

 

 

FPL:

Javascript:

 

goto page REVIEW_PAGE;

 

form.gotoPage(pages.REVIEW_PAGE);

 

o        Right-click on the new button column, select Events, then click the Add Scripts button and add the GOTO_REVIEW_PAGE script. Click OK twice. 

 

Making the table searchable

 

 

FPL:

Javascript:

 

if [ SEARCH_FIELD_INPUT != null ]

  set SEARCH_FIELD_FOR_DB = '%' + SEARCH_FIELD_INPUT + '%';

else

  set SEARCH_FIELD_FOR_DB = '%';

endif

fetchtable CDS;



 

fields.SEARCH_FIELD_FOR_DB.value = "%";

if ( fields.SEARCH_FIELD_INPUT.value )

{

  fields.SEARCH_FIELD_FOR_DB.value += fields.SEARCH_FIELD_INPUT.value + "%";

}

tables.CDS.fetchTable();

 

 

 

o        Right-click on the the Search button, select Events, then click the Add Scripts button and add the APPLY_SEARCH_CRITERIA script.

 

So far we have introduced searching the artist column. We could search on all columns by extending the process above.

 

For more information on database resources and Dynamic SQL see the Database Resources documentation.