How to add details (related grid) to business object

In this example, we will look at:

  • Creation of model and view for business-entity detail
  • Adding a grid with detail edit in previously created edit form

1. Creation of model and view for business-entity detail

1.1 Execute CreateInvoiceDetail.sql script. A table with name “InvoiceDetail” will be created in your database. 1.2 Open Admin of DWKIT 1.3 Open Data Model section. Click Update model link above of the Data Model grid. In the Updating model tree select “InvoiceDetail” table and click Apply button. Data Model item named “InvoiceDetail” must be created. 1.4 Open View section. Click on Create link button above of the View grid. 1.5 Fill Name field with “InvoiceDetail” and select “InvoiceDetail” Data Model as Model field. Click Save button. 1.6 Now you need to select the columns to be displayed and edited.

Amount: set Order = 1, Width = 100, Show = checked, Edit = checked
Date: set Order = 2, Width = 100, Show = checked, Edit = checked

Click on the Save button.

Screenshots:

Screenshot 1

2. Adding a grid with detail edit in previously created edit form

2.1 Open Form section. Click on “Invoice_Edit” form in the Forms grid. 2.2 To add new Block in this Form click on Create link button above of the Blocks grid. Fill Name field with “DetailsRow”, Order field with 20, choose “Form. ROW BEGIN”as Template. Click on the Save and Exit button. 2.3 To add new Block in this Form click on Create link button above of the Blocks grid. Fill Name field with “DetailsCol”, Order field with 21, choose “Form. COL BEGIN” as Template.

Click on Load params button near Template params label. You will see:

@Title=
@HSize=6
@DivId=

in Template params field. Fill this field as:

@Title=Invoice details
@HSize=12

Click on the Save and Exit button.

2.3 To add new Block in this Form click on Create link button above of the Blocks grid. Fill Name field with “DetailsMain”, Order field with 22, choose “Dependent”as Template.

Click on Load params button near Template params label. You will see:

@ViewName=
@Prefix=form
@Width=
@Height=
@BaseEntityIdName=
@BaseEntityIdValue=@id
@CustomSave=true
@SummaryEnabled=
@Mode=2
@IsWindow=false
@EditFormName=
@WindowWidth=
@WindowHeight=

in Template params field. Fill this field as:

@ViewName=InvoiceDetail
@Prefix=form
@Height=250px
@BaseEntityIdName=InvoiceId
@BaseEntityIdValue=@id
@CustomSave=true

Click on the Save and Exit button.

2.4 To add new Block in this Form click on Create link button above of the Blocks grid. Fill Name field with “DetailsColEnd”, Order field with 23, choose “Form. COL END”as Template. Click Save and Exit button. 2.5 To add new Block in this Form click on Create link button above of the Blocks grid. Fill Name field with “DetailsRowEnd”, Order field with 24, choose “Form. ROW END”as Template. Click Save and Exit button. 2.6 Now for detail was saved with the main record we need to change FormCustomSave function in Source field.

Change (line 5)

var stores = [];

to

var stores = [ 
    optimajet.container.form_InvoiceDetail_store,
]; 

Click on the Save button.

Screenshots:

Screenshot 2

Now you can create and edit details in your invoices.