GUID Load On Demand

The GUID Load On Demand field displays a list of options in a drop down combo box that is loaded as the user types in the field. The users input will be used in a target call to filter down the results and display them in the combo box.

The list of items is generated based on the users input. The list will be empty until the user enters some text and filtered results will be returned.

GUID Load On Demand user control, prior to starting to type
GUID Load On Demand user control, with options appearing as the user begins to type

This component requires a target to be specified in its field definition that will be called as the user types to filter the results.

Component Code

The first section of the code for this component includes the parameters and various variables for the component. Below are the methods used by the component.

OnParametersSetAsync()

This method is called when the component initializes and when there’s a change to the parent component. Its purpose is to assign values to variables.

UpdateFilter(ComboBoxReadEventArgs args)

This method is triggered when the user types in the combo box. Its purpose is to take the input the user has entered in the combo box and call GetData and populate the OptionList with the results.

RemapGUIDs()

This method is called by UpdateFilter(). It’s purpose is to check if GUID remapping is needed and do it if so.

GUID remapping is used to validate that the saved item has the correct guid associated with it. For example, I have the following XML saved for this field:

<LoadOnDemandEx GUID="00000000-0000-0000-0000-000000000000">Option A</LoadOnDemandEx>

In this case I have an empty (invalid) guid, so remapping will look to see if there is an Option A in the results from the target, if there is one we’ll update the saved guid with the one returned from the target. The happens when you have an empty guid, or a different guid.

If there happens to be multiple items with the same name, then the guid from the first one will be used.

Task<List<FieldOption>> GetData(string filter)

This method is called when data for the OptionList is needed. Its purpose is to call the specified target in the field definition and return the data from the target for the combo box.

LoadInstance()

This method is called when the JumpButton is selected. If the jump button is enabled, then when an option from the list is selected a jump button will appear next to the combo box. When the button is selected the method attempts to load the instance of the selected option.

GUID Load On Demand user control with the Jump button displayed

ValueChanged()

This method is called when an option from the list has been selected. Its purpose is to ensure the field is modifiable and call ChangeXML if it is modifiable.

ChangeXML()

This method is called by the ValueChanged method. The purpose of this method is to generate XML to save the data for this field and call the ChangeField method on MyInstance and pass the generated XML to it. If auto postback is enabled, it will also save the current instance and reload it.

Below is an example of the XML structure that’s saved:

<LoadOnDemandEx GUID="00000000-0000-0000-0000-000000000000">Option A</LoadOnDemandEx>

DisposeInstanceWindow(DotNetObjectReference<InstanceWindow> instanceWindowObjRef)

This method is called when the instance window component is closed. It’s purpose is to dispose the component hide the window.

Updated on February 13, 2024

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support

Leave a Comment