HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In

Editor templates

Describes templates for the editor.

Custom script

The VisitorGroupCriterion attribute has a ScriptUrl property where you can specify a script file that is used when creating the user interface for a criteria. The ScriptUrl should refer to a JavaScript file that is a valid CommonJS Module which exports a React component as default.

The available packages in your component are React ^16, axios ^0.19 and @episerver/ui-framework ^0.12.


The props passed to your component is a CriteriaEditorProps that looks like this:

interface CriteriaEditorProps{
    name: string;
    editorConfig: Array<CriteriaEditorModelPropertyConfig>;
    settings: any;
    onValueChange: (value: string) => void;initLocalization(path: string): any;translationsLoaded: boolean;
    localization(key: string, fallbackText?: string, values?: any[]): string
interface CriteriaEditorModelPropertyConfig {
    defaultValue: any;
    required: boolean;
    range: ValidRange;
    pattern: string;
    stringLength: ValidRange;
    selectItems: any;
    additionalProps: any;
    label: string;
    typeName: string;
    order: number;
interface ValidRange {min: number;max: number;

The editorConfig property is an array of CriteriaEditorModelPropertyConfig containing all information about each property on the criteria model. The keys are mapped to your model’s property names in camelCase. All attribute decorations and rules for each property are populated here. The property additionalProps contains your additional configuration defined in the CriterionPropertyEditor as JSON.

To use front-end localization, you have to call props.initLocalization(‘path.to.xml.node’) with the path to your XML node. Your translations will be fetched and put in the state. There is a boolean property, translationsLoaded, which indicates when the call is complete. You can then call the localization function to get your translations. This is described further in Localizing the visitor group criterion.

If your model property is an ISelectionFactory, the items are available in the selectItems property.

The settings property holds the saved data for your criteria. It matches the object you emit in the onValueChange function described below.

Save data

For your custom component to be able to save data, you have to pass the data on using the onValueChange prop. Whenever you change your local state also call props.onValueChange, passing in the new state.

const QueryString = (props: CriteriaEditorProps) => {const [localModelState, setLocalModelState] = React.useState({});
    useEffect(() => {
            const state = { ...props.settings }
            setLocalModelState(state);}, []);
    const emitValueChange = (newState: any) => {
    return (
                    onChange={evt => {
                        let newState = { ...localModelState };
                        newState.key = evt.currentTarget.value;
                    options={props && props.editorConfig.condition.selectItems.map(item => {
                        return {
                            label: item.text ?? "",
                            value: item.value?.toString() ?? ""
                    onValueChange={value => {
                        let newState = { ...localModelState };
                        newState.condition = value;
                {localModelState.condition?.toString() === "1" && <TextField
                    style={{ marginLeft: "10px" }}
                    onChange={evt => {
                        let newState = { ...localModelState };
                        newState.value = evt.currentTarget.value;
    export default QueryString