How to properly achieve this context?

I have a static entity Type with this records: Title, HorizontalLine, Section. This static entity "Type" is associated with a "Template" entity, this template entity has a TypeId of Type identifier.


Static entity type have this records:

Title:

Code: "Title"

Label "Title"

TitleHorizontalLineSection: T


HorizontalLine:

Code: "HorizontalLine"

Label "HorizontalLine"

TitleHorizontalLineSection: H


Section:

Code: "Section"

Label "Section"

TitleHorizontalLineSection: S


Then there are another records that have the TitleSeparatorSection "S" because there are different types of sections. For example:

Section1:

Code: "Section1"

Label "Section1"

TitleHorizontalLineSection: S

My doubt is in the Template detail screen I want to have at first one combo box that should show the different types of types "Title, HorizontalLine, Section".

Then, if the user selects the type "Section" on the first combo box it should appear another combo box with the other types that have the TitleSeparatorSection as "S" so the user can select the type of section that he wants. 

Do you know how to properly achieve this? Thanks!

mvp_badge
MVP
Solution

Hello there Jake,

Hope you're doing well.


Unfortunately, with your current datamodel, that is not possible to achieve unless you do some hard coding, which is not correct.


My suggestion is that you create a second Static Entity (call it for instance SubType) where you should have a TypeId attribute (Type identifier) to do this relation between both entities.


One of the combo boxes (the first one) depends on the Type entity (where you have the 3 "parent" records) and the other combo box (the second one) depends on the SubType entity, filtered by the Id of the selected option of the first combo box.


Another option would be to add an additional attribute to your Type entity, which is an Id for the same table (calling for instance ParentId -> Type identifier), where you should specify the parent record. In your case, for the Section1 record, the ParentId would be Entities.Type.Section.

If this value is 0 (not defined), then it means that the record is a "parent" record, otherwise it's a record that depends on another. But you will have to add some conditions to your queries just to show the values that you pretend.

For example, in the first combo box, you will need to filter by ParentId = NullIdentifier(), just to show the "parent" records.


Usually the second approach is used when you want to have a recursive model (N levels). In your scenario, it seems to be only 2 levels (one for each dropdown), so I'd suggest that you consider the first approach :)


Don't forget that you need to use the OnChange event of the first combo box to refresh the query that populates the second combo box (and this query should be filtered by the value selected in the first one).


Hope that this helps you!


Kind regards,

Rui Barradas

Hi Jake,

Add onchange action on first dropdown and add a filter in template entity (entity will have foreign key of static entity) of first drop down selected id and and refresh the template entity in onchage action and use template entity in 2nd dropdown source.

Regards,

Komal

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.