Class ContextManagerCustomScripting

This class supports the functionality for custom scripting on a context manager. You can access all the methods by using the namespace CSL.contextManager.

Hierarchy

  • CslBase
    • ContextManagerCustomScripting

Properties

componentId: string = ''

The component id of the current view instance.

parserService: ParserService = ...

SERVICES

Accessors

  • get componentConfig(): Component
  • The configuration of the component to render.

    Returns Component

  • get htmlElement(): any
  • The rendered HTML of the view.

    Returns any

  • get viewConfig(): UpdateView | MultiRecordView | SingleRecordView | CreateView
  • The configuration of the view to render.

    Returns UpdateView | MultiRecordView | SingleRecordView | CreateView

  • get viewFields(): ViewField[]
  • The viewFields of the view.

    Returns ViewField[]

Methods

  • Sets the hide condition on context manager field(s). The hide condition cannot be configured on a context manager field which is configured to be hidden. When specifying a component id, that component is targeted, otherwise the current context in which the function is called will be taken. The condition will be checked when an interaction in the context manager is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the context manager, the most logical place to call this function is in the configuration script.

    CSL.contextManager.addHideFieldCondition((rowData) => {
    return rowData.productActive;
    }, ['productName'], componentId);

    Parameters

    • condition: Function

      The condition that returns a boolean that indicates whether the field needs to be hidden.

    • fieldNames: string[]

      The names of the context manager fields to set the condition on.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Clear the current context manager.

    CSL.contextManager.clear();
    

    Parameters

    • Optional componentId: string

      The id of the context manager to clear.

    Returns void

  • Clear all context managers.

    CSL.contextManager.clearAll();
    

    Returns void

  • Gets the context value for a specific field.

    CSL.contextManager.getContextValue('name');
    

    Parameters

    • fieldName: string

      The field of which you want to know the value for.

    Returns string

  • Get all context of the current page.

    Returns ValueObject<string>

  • Removes the hide condition on context manager field. If the field is configured as 'hidden' the field will always be hidden. When specifying a component id, that component is targeted, otherwise the current context in which the function is called will be taken.

    CSL.contextManager.removeHideFieldCondition(['productName', 'productDescription'], componentId);
    

    Parameters

    • fieldNames: string[]

      The names of the context manager fields to set the condition on.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Triggers the search of a context manager.

    CSL.contextManager.search();
    

    Parameters

    • Optional componentId: string

      The id of the context manager to search.

    Returns void

  • Sets the given context as context. Overrides if the key of a field was allready in use.

    // Set for the field 'name' the value 'John' in context.
    CSL.contextManager.setContextValue('name', 'John');
    // Set an object as context.
    CSL.contextManager.setContextValue({'name': 'John', 'age': 35});
    // Set for the 'name' field the value 'John' in context, without triggering the context change event.
    CSL.contextManager.setContextValue('name', 'John', false);

    Parameters

    • context: string | {
          [key: string]: any;
      }

      The context to set or the key of the context.

    • Optional contextValue: any

      The value for the key.

    • emitContextChange: boolean = true

      The conditional to emit context change event or not. Leaving this parameter to its default value or setting it to true will remain as it used to be, meaning the ADM will refresh itself if it's listening to the context manager.

    Returns void

  • Gets or sets the values of the context manager component. The context manager's search will also be triggered and the context will be set when the search button is not visible. Best practice is to set values of the correct type for the control. For example a number for a number field, a date for a date field, ... We will try to parse the 'incorrect' value to the correct type, but we can not guarantee the correct value will be set.

    CSL.contextManager.values(); // Returns all values of the form
    CSL.contextManager.values({'name': 'John', 'stock': 500, 'delivery': new Date('4-27-2020'), 'isActive': true}, undefined, 'a35b'); // Returns all values of the form after setting values.
    CSL.contextManager.values({'name': 'John'}, ['name', 'stock'], componentId); // Returns the values for 'name' and 'stock' after setting value for 'name'

    Parameters

    • Optional valuesToSet: {
          [key: string]: any;
      }
      • [key: string]: any
    • Optional viewFieldNames: string[]
    • Optional componentId: string

    Returns any

Generated using TypeDoc