Screen scaffolding: controls

From OpenPetra Wiki
Revision as of 11:07, 3 September 2009 by Pokorra (talk | contribs) (→‎Events)
Jump to navigation Jump to search

Control Hierarchy

Root Control: Usually, the first Pagecontrl (tab), GroupBox (grp), User contrl (uco), or Panel (pnl). Sometimes, especially with inheritance of the forms, this does not work. So you can set the attribute RootControl=true for the control that you want to be the root. (this behaviour is implemented in Ict.Tools.CodeGeneration.TCodeStorage.GetRootControl)

Detail: if you have the word Detail in front of a control name, just after the control prefix, this means that the control belongs to the detail table.

grdDetails and pnlDetails are special controls which have special meaning for disabling the detail controls etc

Layout of Controls

  • use Dock=Fill, or Dock=Top, or Dock=Bottom
  • use Width=200 for setting the width of eg a txt control
  • use Panels (pnl) to group controls
  • by default, the controls are arranged vertically (each control below the previous control)
  • to have the controls in one row, use ControlsOrientation = horizontal
  • to arrange controls in a grid, use several RowX, RowY, etc as sub elements of Controls; the elements of each row are arranged horizontally.
  • use ColSpan=2 to span a control over two columns
  • Label sets the label for the control, otherwise it is built from the control name, without prefix
  • NoLabel=true will generate the control without a label

Attributes for controls on report screens

  • ParameterName: will use the given name for the parameters that are sent to the server; otherwise it will be built from the control name
  • NoParameter=true: will ignore the control, eg the ledger name text field is readonly, and is only for information

Control Types

  • pnl: Panel
  • uco: User defined control; needs attribute Type with the value containing the full namespace for the control, eg:
       ucoPersonnelTabSet:
           Type: Ict.Petra.Client.MPartner.Gui.TUC_PartnerEdit_PersonnelTabSet
  • tab: Page Control, consisting of tpg (tabbed pages)
    • DragTabPageEnabled: allow rearranging the order of tab pages (default: true)
  • grp: Groupbox
  • chk: Checkbox
  • grd: Grid control
    • use SelectedRowActivates to enable a condition when a row is selected
    • use event ActionFocusRow that is called when the selection of the current row changes
    • special control with name "grdDetails" is required for the Master/Detail screens
    • property SortOrder defines which column should be sorted. Several columns can be separated by commas; it is necessary to add DESC or ASC; example: SortOrder: ABatch.BatchNumber DESC
  • btn: Button
  • nud: Numeric Up/Down
    • has a second label LabelUnit, which can be optionally set
    • use PositiveValueActivates to enable a condition when a positive value is selected
  • txt: normal edit field
    • special behaviour for Type=PartnerKey and Type=Extract; Type=Currency
  • rbt: simple radio button
  • rgr: radio button group
    • this can contain several other controls in Controls list, which will create radiobuttons with the controls for each item
    • or can just contain text in value OptionalValues, which will create radiobuttons for each text
  • chk: checkbox
    • can have a list of dependent other controls in Controls list
  • rng: enter 2 values that define a range
    • this is basically a special panel
  • cmb: Combobox; usually uses Ict.Common.Controls.TCmbAutoComplete
    • attribute OptionalValues defines the values of the combobox; prepend the default option with equals sign
      • sample: OptionalValues: [=Days, Weeks, Months]
    • attribute List: this will load the values from the server (and use a cache as well); it will use cmbAutoPopulatedComboBox instead of TCmbAutoComplete
      • possible values for list: eg. CurrencyCodeList
      • sample: cmbCurrency: {Label=&Currency, DataField=AApSupplier.CurrencyCode, List=CurrencyCodeList}
    • attribute AutoComplete: this will store the entered search strings in the user defaults
      • cmbSupplierCode: {Label=S&earch Supplier, AutoComplete=SupplierSearchHistory, Tooltip=Search by supplier name or partner key}
    • attribute: MultiColumn: this will generate a TCmbVersatile combobox with several columns; make sure to set the column width of the second or more columns, otherwise they will not be visible! (not used yet anywhere)

Data Binding

We don't use .Net databinding, but the generator wires the data.

  • You can use the attributes MasterTable and DetailTable that will try to match each control to the field in the table with the same name (detail fields must be called <prefix>Detail<fieldname>, eg. txtDetailAmount)
  • You can specifically bind data with DataField, either with the data table name or just the field name.
    • sample: DataField=AApSupplier.CurrencyCode
  • For some controls, eg radiobuttons used for filtering the displayed data, you need to avoid that the Save button gets activated: use SuppressChangeDetection: true

special lookups

  • PartnerShortNameLookup: this is for printing the partner short name on a screen; usually this is readonly; but you need to specify that with ReadOnly=true
    • sample: txtSupplierName: {Label=Current Supplier, ReadOnly=true, PartnerShortNameLookup=AApDocument.PartnerKey}

special behaviour

  • if you link a boolean database field to a combobox with 2 values, it will match the value (first value is false, second value is true).
    • sample:
      OptionalValues: [=Invoice, Credit Note]
      DataField: CreditNoteFlag

Events

  • attribute OnChange points to a function that is called if the value in the control changes
    • sample: dtpDateIssued: {Label=&Date Issued, OnChange=UpdateCreditTerms}
  • attribute Action points to an action that is executed for Click etc
    • actually, there is now a convention, ie. the name of the control matches the name of the action, and the sample would not be even necessary
    • sample: mniNewSupplier: {Action=actNewSupplier}
  • attribute ActionClick/ActionDoubleClick points to a function that is called if the control is clicked
    • sample: grdSupplierResult: {Dock=Fill, ActionDoubleClick=actSupplierTransactions, SelectedRowActivates=cndSelectedSupplier}
  • attribute ActionOpenScreen will open a screen (defined with full namespace); if PropertyForSubScreens is set for the form, and the new screen has that propery too, it will be assigned
    • sample: mniAccountsPayable: {Label=&Accounts Payable, ActionOpenScreen=Ict.Petra.Client.MFinance.Gui.AccountsPayable.TFrmAPMain}
  • in a grid: attribute SelectedRowActivates: activate a condition/action, which other actions can depend on
  • in a grid: ActionFocusRow is called when the selection of the current row changes