Kentico 9: Parent/Child User Interface

Donnie Hyatt asked on October 26, 2016 17:29

I have created a custom module (actually I have created a handful in recent years, and this same obstacle frustrates me every time) following the Kentico documentation:

The problem I end up with every time, is in developing the User Interface for Parent/Child classes. I create a Vertical Tab node, and beneath it I add an edit tab and a Binding tab for the child class. This all works, and I can add and remove bindings at will, but what I can't do is ADD a new child class and bind it.

Custom Module User Interface Configuration

Using the Standard Edit Binding template, I am able to bind EXISTING Job Titles to the selected Category, but I cannot CREATE a new one from that page:

Standard Binding Missing Add Funstionality

To solve this, I created a custom Edit Binding template, and added a New Child Class Header Action that points to a New / Edit Object child:

enter image description here

enter image description here

Which gives me a button that I can use to add a new child class (Job Title):

enter image description here

This approach works per se, in that I can click the New Job Title button and create a new item on the subsequent page:

enter image description here

But no binding is created to link the child object (Job Title) to the selected parent object (Category), An even bigger problem is that once I click Save, I am presented with the following:

enter image description here

The new object DOES SAVE, but the post-save navigation is somehow failing. The event log offers little in the way of diagnostics:

enter image description here

So I thought to create a completely custom interface to accomplish my needs here, according to the Kentico documentation:

So I change the Element Content of the New Job Title page to a custom page that I created to post a DataForm for the new object:

enter image description here

Taking care to assign the proper Object Types on the Properties Tab:

enter image description here

The intent was to programmatically create the binding upon save and also handle the correct navigation to avoid the ambiguous parameter error above, but when this page loads, the UIContext.ObjectID and UIContext.ParentObjectID are both 0:

enter image description here

So I cannot create the binding programmatically. I was able however to solve the error that I received by manually assigning the redirect. The experience is still lacking even with this hack, since it returns to the listing page, but the user still has to click "Add Items" to assign the binding after successfully creating it with the custom page I built.

This cannot be the proper way to do this, so any help with getting me on the right track would be greatly appreciated.

Recent Answers

Dawid Jachnik answered on October 27, 2016 10:14


First of all: Questions on stack overflow tagged Kentico are displayed here in Q/A

Answering your question, why don't you clone New / Edit Object template and modify only redirect after save? By default this template refers to codename starting with "Edit" for that object.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on October 27, 2016 10:27

Donnie, I've created parent-child or many-to-many (binding in Kentico terminology) for a couple of times, but never had similar issue. I'd recommend verifying TYPEINFO initialization/settings for your *Info classes - sometimes they are tricky.

0 votesVote for this answer Mark as a Correct answer

Donnie Hyatt answered on October 27, 2016 14:57

Dawid - Thanks for the heads up about the Stackoverflow tag, I was unaware of that. As for the template clone, That's effectively what I've done (the custom page I created does that, but I wanted to create the Binding programmatically as well).

Do you have advice on how to create the binding from that New / Edit Object Template, or how to propogate the binding IDs to the custom page?

0 votesVote for this answer Mark as a Correct answer

Donnie Hyatt answered on October 27, 2016 14:59

Roman - When you say you've never had similar issue, do you mean that you have been able to place a New Item button on your Add / Edit Binding template, create a new child class with it and have a binding created that relates to the parent that you are currently editing?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.