Tech Tip: Dynamically Change Type-ahead

Tech Tip: Dynamically Change Type-ahead

In 11.0 SP11, type-ahead was introduced to List and Item fields to make editing forms easier and more convenient for Users. When a user types in one of these fields, a dynamic list of options will be shown based on what the user has typed in to the field. You can see this functionality in action below as we assign a Designated User to one of our Parts.

In this post, we'll cover how we can manipulate this type-ahead functionality to make work even easier for our users.

Dynamically Populate Dropdown

One common question we hear on the forums is how to dynamically populate a dropdown field.

The example below explores the use case of wanting to limit the selection of Authoring Tools on the Document Form. In this use case, we only want users to be able to pick Microsoft Office tools when creating and editing Documents. To accomplish this, we will first query for a subset of the Values on the Authoring Tools List. Once we have these values, we will construct an array of javascript objects that will represent each option we want to be available in the dropdown.

You can easily adapt this code to populate a completely empty dropdown as well.

Filter Item Field Type-Ahead

A few months ago, we put out a blog that demonstrated how to apply a filter to a search dialog. One question we received on this post was how to apply the same filter to the options in the type-ahead of the field as well. The sample code below shows precisely how to do that by overriding the call to the server that generates the options for the type-ahead.

This sample ensures that only specific, individual Users can be assigned as the creator of a Part. If we compare the clip below to the one at the beginning of this post, we'll notice that Group Identities like Manufacturing are no longer offered.

LOOKING FOR MORE ARAS INSPIRATION?

Subscribe to our blog and follow @ArasLabs on Twitter for more helpful content! You can also find our latest open-source projects and sample code on the Aras Labs GitHub page.