Custom dropdowns managed by the editors in a few minutes

I noticed that our current documentation for Custom tables is missing one important piece which may not be obvious, so just for case I want to show you how you can do custom selectors managed by the Kentico CMS UI.
Hi again,

Customizing the form controls is quite often thing, expecially if you are dealing with some predefined lists and dropdown (combobox), radiobutton or checkbox lists and others. With Kentico CMS, it is very easy to do such customization and the list can be managed by the end user.

Let's pretend you want to have a dropdown with something on your document form. For instance, we can have a restaurant menu in the Kentico CMS's web site, and the meal may have some type (pasta, pizza, soup, etc.). And we want to let the editors manage these types, not the developer.

Module custom tables

First, we need to prepare the data, so we will need some list of the options and their values which will be saved to the document. For the detailed documentation for custom tables, see and learn

Now you can easily create a new custom table with display name "Meal type" and code name "customtable.mealtype".

We will leave the default table name "customtable_MealType" (remember that) and use just the ID and Order fields as the default, because we want to order the items.

Then we add two new fields:

MealTypeName: Text, 100 characters, Visible in form with caption "Meal type name" and using TextBox control.

MealTypeValue: Text, 100 characters, Visible in form with caption "Meal type value" also using TextBox control.

Finish the wizard and go to the CMS Desk -> Tools -> Custom tables, you can manage the list so just create some options. I created these as an example:

Now you have the list which can be managed by the end user.

Define the dropdown (other control)

Go to your document type (any, ours could be Meal), and add a new field:

MealType: Text, 100 characters, Displayed in form with caption "Meal type" as Drop-down list

The last thing you need to do is to get the data from database to your dropdown. To do that, select the SQL query source and type in:

SELECT MealTypeValue, MealTypeName FROM customtable_MealType ORDER BY ItemOrder

And you get the list to your dropdown properly ordered as it was edited by the end user.

And that's it! When you edit or create the document, you have the dropdown on the form, and it contains precisely what the user who is managing the list entered in the list.

When you save the document, the value assigned to the meal type will be saved to the database so even when you change the name, the right option will be always selected from an existing document.

You can do the same for your wiki (live site) editors to allow them only predefined set of options.

How complicated was that? Not at all ...

You can do the same (well, similar and without the order functionality) with BizForms module in previous versions, we just didn't wanted you to have to use them without being able to set the access to particular ones and also from the architectural point of view it is not right to save the data in the online forms module meant for completely different thing.

So wherever you would use BizForm for storing your data (some of you already use it this way), you can use custom tables now. It is much clearer solution.
Share this article on   LinkedIn

Martin Hejtmanek

Hi, I am the CTO of Kentico and I will be constantly providing you the information about current development process and other interesting technical things you might want to know about Kentico.


Martin Hejtmanek commented on

Hi Dimitris,

You need to get the custom table items in your transformation using our API, see some examples here: I strongly recommend you to cache the results.

Dimitris Rakopoulos commented on

I used this example to create a custom table in order to populate a drop down list on a document type. However, I used the itemID and the name field to store the data on the document type. How can I select this field on a transformation in order to display the actual content of the custom table.

To make it more clear. My custom table has one field named ClientName and the automatically generated itemID. On the document type I use the itemId and the ClientName on the sql statement of the drop down menu. How can I display this information (the ClientName) on a transformation?

Thank you,

Martin Hejtmanek commented on

Hi Dimitris. It is quite easy, see our filter example in the Products section of our sample E-commerce web site and make one similar to that. Use CustomTableItemProvider.GetItems to get the data for the dropdown.

Dimitris Rakopoulos commented on

How easy or difficult is it to create a drop down in order to filter a list of custom data or products?

JimS commented on

That's a useful part of the puzzle for one of my projects, for which I'm still considering Portal vs. Webpart vs. ASPX. Thanks vm.