0
votes

i have a form with two grids. Each grid has it own datasource. For more information look at the attached picture.

On dependence which line i select in the first grid, the content of the second grid will change.

Now my problem: If i create a new row on the first grid, i am not able to enter values in the second grid because ax don't give me a new "combinationID" (Primary field, INT)

enter image description here

How can i solve this?

2
How are you populating combination id in first grid? Is it by number sequence? In any case after super in insert method of the first grid table, insert a new record in second grid table with the combination id as in first grid table. - Pradeep Muttikulangara Vasu

2 Answers

1
votes

This looks like a parent-child form where the upper grid is your "header" and the lower is your "lines".

If CombinationID is your primary key, it should probably be generated via number sequence or unique somehow.

On the form, the DataSource MDISSearchDimensions's property JoinSource should be set to MDISAccountSearchTerms. It will use the table relation, but you need to specify they're joined.

Then once your CombinationID is set from the header, you just need to make sure the lines get it. On the table MDISSearchDimensions, add a method called initFromMDISAccountSearchTerms(MDISAccountSearchTerms _MDISAccountSearchTerms), which sets the CombinationID and call this method inside MDISSearchDimensions.initValue().

0
votes

You should disable the InsertIfEmpty property of the second datasource.

The initValue method of the second datasource initializes the CombinationId field (provided proper relations) to the master CombinationId datasource value, but now it does so before the master datasource field has a value.

You have another option if want to leave it on; set it manually in validateWrite of the second datasource:

public boolean validateWrite()
{;
     MDISAccountDimension.CombinationId = MDISAccountSearchTerms.CombinationId;
     return super();
}

Thus it will no longer fail due to Mandatory being set.

You should hide the CombinationId in the second grid to avoid user errors.