Showing and Hiding Configuration Options

Compatibility

The content of this page can only be used if the following condition(s) are all met:

  • You must target the Vault Application Framework 2.0 or higher.

Some configuration settings are only applicable in specific scenarios, and showing all configuration options to users may not be the most user-friendly. In these situations, configuration options may be shown or hidden depending on the state of other options.

JSPath

The ShowWhen and HideWhen configuration both use JSPath syntax to define both the trigger property to test, and the condition which it must meet. More information on the JSPath syntax is available on the JSPath official GitHub repository.

Showing or hiding options depending on configuration state

In the example below, the AdvancedConfiguration option is hidden by default and only shown when the user sets the UsesAdvancedConfiguration option to true.

Advanced configuration options hidden Advanced configuration options shown

using System.Collections.Generic;
using System.Runtime.Serialization;
using MFiles.VAF;
using MFiles.VAF.AdminConfigurations;

namespace MFVaultApplication1
{
	[DataContract]
	public class Configuration
	{
		[DataMember]
		public bool UsesAdvancedConfiguration { get; set; }

		[DataMember]
		[JsonConfEditor(
			Hidden = true,
			ShowWhen = ".parent._children{.key == 'UsesAdvancedConfiguration' && .value == true }")]
		public AdvancedConfiguration AdvancedConfiguration { get; set; }
	}

	[DataContract]
	public class AdvancedConfiguration
	{
		[DataMember]
		public string Value { get; set; }
	}


	public class VaultApplication
		: VaultApplicationBase, IUsesAdminConfigurations
	{

		private ConfigurationNode<Configuration> config { get; set; }

		/// <inheritdoc />
		public void InitializeAdminConfigurations(IAdminConfigurations adminConfigurations)
		{

			// Add it to the configuration screen.
			this.config = adminConfigurations.AddSimpleConfigurationNode<Configuration>("My Vault Application");
		}
	}
}