Site structure
Version 7.x > Site structure > Document Type with related field View modes: 
User avatar
Member
Member
jeff2001 - 2/11/2014 6:51:12 AM
   
Document Type with related field
Im looking at creating a document type that has a dropdown box. This dropdown is populated via sql query. Once the user selects an option a new multiple choice field is populated by taking the value from the dropdown and running another sql statement to populate the options. The selection is only for CMSDesk side of things.

An example would be having a dropdown of states/provinces. Each state has stores associated with it. When someone selects a given state it will list the stores available in the region. You can then select the stores for which this document would show up.

Is this possible ?

Thanks

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 2/11/2014 8:39:35 AM
   
RE:Document Type with related field
Hi,

Yes, it is possible to develop such a custom form control which will consist of two controls and on the selection change event of the first one, you will load values to the second one.

Best regards,
Juraj Ondrus

User avatar
Member
Member
jeff2001 - 2/12/2014 7:31:41 AM
   
RE:Document Type with related field
Thats great and seems to be working with a few manual steps. What I can't figure out is how to reference that dropdown. I am currently trying to do this:

string promotiongroup = ValidationHelper.GetString(Form.GetFieldValue("PromotionGroup"), "NewPromo");

The name of the Drop down list in the document type is PromotionGroup.

Also when i save it seem to give an error, I was assuming it would save the value into the DB from public override Object Value, is that correct ?

Thanks Again

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 2/13/2014 1:05:54 AM
   
RE:Document Type with related field
Hi,

I am sorry I am not sure what you mean exactly. What is the code of the custom form control? It should consist of the drop down list control and the multiple choice control. You will fill the drop down on the first load and then, in the selected item changed event of the drop down, you will generate the multiple choice control according your conditions.

Best regards,
Juraj Ondrus

User avatar
Member
Member
jeff2001 - 2/13/2014 7:59:45 AM
   
RE:Document Type with related field
I wanted the value of the dropbdown to be saved in 1 db field and the multichoice in another, so I added a plain dropdown in the kentico system and then created a custom control for the multiple choice with a CheckBoxList. I assumed I would be able to access the dropdown value from the custom control or is that incorrect.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 2/14/2014 3:46:05 AM
   
RE:Document Type with related field
Hi,

It is possible but it is more complicated than making the cusotm form control to save values into separate fields. This will require to understand how the Form engine works (webinar video). Or, you can create fully custom form used on the Form tab with custom C# code that will refresh the page and reload the control values according your rules, using AJAX or javascript. then, you will set this ASPX form in the document type properties on the General tab -> Editing Form page setting.

Best regards,
Juraj Ondrus