HOWTO - Sashipa development

 Advanced listForm.

You have a listForm and you wish to modify its behaviour, or to add a column of a linked table, or to display a computed agregate column...

How to modify appearance or behaviour of a listForm

If you want to not display column titles, or to not display number of lines, or to not allow deleting or to not display a "add" button:

  <listForm db='dbContact' delete='no' displayColumnTitles='no' displayRowCount='no'>
    <!-- ... -->
    <insertScreen screen='SCtblContactAddress' schemaFk='fk_tblAddress_tblContact' />
    <doubleClicScreen screen='SCtblContactAddress' />
    <!-- ... -->

Remarks :

Adding a column of a linked table, and displaying an agregate - simple version

Here is an example:

  <listForm db='dbContact' delete='yes'>
    <bounds x='10' y='90' w='600' h='350' />
    <schemaTableRef schemaTable='tblContact' />
    <instanceColumnList>
      <instanceColumn schemaColumn='tblContact_ContactName' />
      <instanceColumn schemaColumn='tblContact_ContactFirstname' />
      <instanceFkColumns join='inner'>
        <instanceFk schemaFk='fk_tblContact_tblProfession' />
      </instanceFkColumns>
      <agregatInstanceColumn schemaFk='fk_tblAddress_tblContact' letterCount='4'
                             sort='desc' type='count'>
        <title>Nb Adr</title>
      </agregatInstanceColumn>
    </instanceColumnList>
    <doubleClicScreen screen='SCtblContact' />
    <insertScreen screen='SCtblContact' schemaFk='fk_tblContact_tblProfession' />
  </listForm>
  <!-- ... -->

The instanceFkColumns element displays the user-key columns of the referenced table (cf userKey element in the environment part of the Sashipa code).

NB: the attribute "join='inner'" means that join is an "inner join". It's better for good performances when executing the SQL query. But if your foreign key can be null, then "join='left'" must be used. Otherwise rows with a null foreign keys will be ignored !

The agregatInstanceColumn element displays the number of rows in tblContactaddress, that reference the current Contact. Here a left join is needed.

Attributes in instanceColumn elements

The Attributes of an instanceColumn element are optional. Default values for these attributes are defined in the schemaColumn element (in the environment part). Here is an instanceColumn with all attributes:

  <instanceColumn schemaColumn='tblContact_ContactName' letterCount='20' sort='asc' order='0' />

Explications:

How to define the screen that displays the content of a row

The screen that displays the content of a row is defined in the element doubleClicScreen. More often the referenced card is filtered on the primary key value of the selected row. Like this :

  <listForm db='dbContact' delete='yes'>
    ...
    <schemaTableRef schemaTable='tblContact' />
    ...
    <doubleClicScreen screen='SCtblContact' />
    <insertScreen screen='SCtblContact' schemaFk='fk_tblContact_tblProfession' />
  </listForm>
  <!-- ... -->

Here the same card 'SCtblContact' is used for both adding and modifying. But the value of a foreign key can be used too (and not this of the row primary key). For example when the listForm display the content of a SQL table, that contains only two foreign keys : modifying the content of a row is not usefull. An example:

  <listForm db='dbContact' delete='yes'>
    ...
    <schemaTableRef schemaTable='tblRegisteredInGroup' />
    ...
    <doubleClicScreen screen='SCtblIndividual'>
      <filterWithInstanceFk schemaFk='fk_tblRegisteredInGroup_tblIndividual' />
    </doubleClicScreen>
    <insertScreen screen='SCtblRegisteredInGroup' schemaFk='fk_RegisteredInGroup_tblGroup' />
  </listForm>
  <!-- ... -->

In this example there are "Groups" composed by "Individuals", each individual can be registered in several groups. This listForm is in the card of "Group". It displays individuals that are registered in the group. When adding, the card of Registration (SCtblRegisteredInGroup) is displayed. But on double-click the card of the referenced individual is directly displayed.

Another example of using this skills is about displaying SQL views.

© Copyright 2003 Sashipa-Melba Team. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License as much as this note clearly appears.