Class ViewCustomScripting

This class represents the API for custom scripting related to views. You can access all the methods by using the namespace CSL.view.

Hierarchy

  • CslBase
    • ViewCustomScripting

Properties

componentId: string = ''

The component id of the current view instance.

createViewFieldGroupContentSettings: ((styles?: {
    [key: string]: string;
}) => ViewFieldGroupContentSettings) = createViewFieldGroupContentSettings

Type declaration

    • (styles?: {
          [key: string]: string;
      }): ViewFieldGroupContentSettings
    • Creates a new instance of settings that can be applied to the group content.

      Parameters

      • styles: {
            [key: string]: string;
        } = {}

        Any custom styles to apply to the content.

        • [key: string]: string

      Returns ViewFieldGroupContentSettings

createViewFieldGroupHeaderSettings: ((title?: string, color?: string, backgroundColor?: string, styles?: {
    [key: string]: string;
}) => ViewFieldGroupHeaderSettings) = createViewFieldGroupHeaderSettings

Type declaration

    • (title?: string, color?: string, backgroundColor?: string, styles?: {
          [key: string]: string;
      }): ViewFieldGroupHeaderSettings
    • Creates a new instance of settings that can be applied to a group header.

      Parameters

      • title: string = ''

        The title of the group.

      • color: string = 'inherit'

        The color of the text.

      • backgroundColor: string = 'inherit'

        The background color of the header.

      • styles: {
            [key: string]: string;
        } = {}

        Any custom styles to apply to the header.

        • [key: string]: string

      Returns ViewFieldGroupHeaderSettings

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

  • Adds a button to the view

    CSL.view.addButton('googleButton', 'fab fa-google', 'Go to Google', () => {window.open('//google.com')}, componentId);
    

    Parameters

    • buttonName: string

      The name for the button.

    • icon: string

      The icon used for the button.

    • label: string

      The label for the button.

    • onClick: Function

      The function executed when the button is clicked.

    • Optional componentId: string

      The id of the component where the button will be added.

    Returns void

  • Add a condition that sets class(es) on a view field. The condition will be checked when an interaction in the view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the view, the most logical place to call this function is in the configuration script.

    CSL.view.addClassCondition(['productName', 'productDescription'], (rowData) => {
    if (rowData['productActive']) {
    return 'product-active product-highlight';
    } else {
    return 'product-inactive';
    }
    });

    Parameters

    • fieldNames: string[]

      The names of the view fields that will be affected by the condition.

    • condition: Function

      The condition that returns the classes to set.

    • Optional componentId: string

      the id of the component.

    Returns void

  • Sets the hide condition on view field. The hide condition cannot be configured on a view 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 view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the view, the most logical place to call this function is in the configuration script.

    CSL.view.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 view fields to set the condition on.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Adds an action to the view fields specified.

    // Open dialog to update a product.
    const updateProductAction = {
    // Name of the field where the action will be placed on.
    viewFieldName: 'productName',
    // Name of the fields that should be updated with value filled in the dialog.
    viewFieldsToUpdate: ['productName', 'productDescription'],
    // The settings for the action, what view to open.
    actionSettings: {
    objectName: 'Product',
    viewName: 'Update Product'
    }
    };

    // Open dialog that show all vendors
    const getAllVendorsAction = {
    viewFieldName: 'vendorName',
    actionSettings: {
    objectName: 'Vendor',
    viewName: 'Get All Vendors',
    },
    icon: 'fas fa-truck-moving', // Overwrite the default icon
    description: 'Vendors' // The description (tooltip)
    };

    CSL.view.addViewFieldAction([updateProductAction, getAllVendorsAction]);

    Parameters

    • actionSettings: ViewFieldAction[]

      Specifies the behaviour of the action linked to the view field.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Creates a new group instance.

    Parameters

    • layout: Layout

      The layout direction of the children.

    • children: (string | ViewFieldGroup)[]

      The children of the row.

    • Optional header: string | ViewFieldGroupHeaderSettings

      The settings for the header.

    • Optional content: ViewFieldGroupContentSettings

      The settings for the content.

    • styles: {
          [key: string]: any;
      } = {}

      Any custom styles to apply to the row.

      • [key: string]: any

    Returns ViewFieldGroup

  • Creates a new group with layout direction set to column.

    Parameters

    • children: (string | ViewFieldGroup)[]

      The children of the group.

    • Optional header: string | ViewFieldGroupHeaderSettings

      The settings for the header.

    • Optional content: ViewFieldGroupContentSettings

      The settings for the content.

    • styles: {
          [key: string]: any;
      } = {}

      Any custom styles to apply to the group.

      • [key: string]: any

    Returns ViewFieldGroup

  • Creates a new group with layout direction set to row.

    Parameters

    • children: (string | ViewFieldGroup)[]

      The children of the group.

    • Optional header: string | ViewFieldGroupHeaderSettings

      The settings for the header.

    • Optional content: ViewFieldGroupContentSettings

      The settings for the content.

    • styles: {
          [key: string]: any;
      } = {}

      Any custom styles to apply to the group.

      • [key: string]: any

    Returns ViewFieldGroup

  • Triggers the delete function of a view. Multi record views will take all selected items into account. Single record will take found record into account. There will be NO confirmation box to ask if you want to delete the record(s).

    CSL.view.deleteRecord(componentId).then((result) => {
    console.log(result)
    },
    (error) => {
    console.error(error);
    });

    Parameters

    • Optional componentId: string

      The identifier of the component.

    Returns Promise<ListItemFunctionExecutionResults>

  • Edit the cell of the inline editing grid.

    Deprecated

    Inline editing is under development. The namespace will be changed after inline editing is implemented.

    Returns void

  • Get the configuration of view fields.

    let viewConfigs = CSL.view.getConfiguration(['productName', 'productStock']);

    viewConfigs.forEach((config) => {
    console.log(config);
    });

    Parameters

    • viewFieldNames: string[]

      The names of the view fields.

    • Optional componentId: string

      The id of the component.

    Returns ViewField[]

  • Whether the button exists on the component.

    // Add a button
    CSL.view.addButton('googleButton', 'fab fa-google', 'Go to Google', () => {window.open('//google.com')}, componentId);
    CSL.view.hasButton('googleButton', componentId); // True

    // Remove button
    CSL.view.removeButton('googleButton', componentId);
    CSL.view.hasButton('googleButton', componentId); // False

    Parameters

    • buttonName: string

      The name of the button.

    • Optional componentId: string

      The id of the component.

    Returns boolean

  • Check whether the grid is in inline editing mode

    Deprecated

    Inline editing is under development. The namespace will be changed after inline editing is implemented.

    Returns boolean

  • Leaves the cell in the inline editing grid.

    Deprecated

    Inline editing is under development. The namespace will be changed after inline editing is implemented.

    Returns void

  • Sets the view into a processing state.

    // Set current view in progress.
    CSL.view.progress();
    // Set the view with component id "3" in progress.
    CSL.view.progress(true, '3');
    // Remove the progress from view with component id "3".
    CSL.view.progress(false, '3');

    Parameters

    • processing: boolean = true

      Whether the view need to set in processing.

    • Optional componentId: string

      The id of the component to set in processing.

    Returns void

  • Remove a button from the component.

    // Add a button
    CSL.view.addButton('googleButton', 'fab fa-google', 'Go to Google', () => {window.open('//google.com')}, componentId);
    CSL.view.hasButton('googleButton', componentId); // True

    // Remove button
    CSL.view.removeButton('googleButton', componentId);
    CSL.view.hasButton('googleButton', componentId); // False

    Parameters

    • buttonName: string

      The name of the button.

    • Optional componentId: string

      The id of the component for which the button needs to be removed.

    Returns void

  • Remove the class condition on view fields specified.

    CSL.view.removeClassCondition(['productName', 'productDescription']);
    

    Parameters

    • fieldNames: string[]

      The name of the view fields.

    • Optional componentId: string

      the id of the component.

    Returns void

  • Removes the hide condition on view 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.view.removeHideFieldCondition(['productName', 'productDescription'], componentId);
    

    Parameters

    • fieldNames: string[]

      The names of the view fields to set the condition on.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Sets a custom template for the multi record view. Refer to: http://docs.ometa.net/public/articles/data-visualisation/views/custom-renderer/custom-renderer.html

    let templateFunction = function(rowData, formattedData, csl) {
    return `
    <div>${rowData.myField}</div>
    `;

    CSL.view.setCustomTemplate(templateFunction);
    }

    Parameters

    • templateFunction: Function

      Function that will be called for each record in the page. Should return the HTML which will be rendered as a string.

    • containerClass: string = ''

      Css classes applied on the single container.

    • elementClass: string = ''

      Css classes applied on each element in the loop.

    • Optional emptyTemplateFunction: (() => string)

      Function that will be called when there are no records. Should return the HTML which will be rendered as a string. If unspecified, the no result message is displayed.

        • (): string
        • Returns string

    • Optional customTemplateProperties: CustomTemplateProperties

    Returns void

  • Sets the default header settings for a view field group.

    Parameters

    • color: string = 'inherit'

      The color to apply by default.

    • backgroundColor: string = 'inherit'

      The background color to apply by default.

    • styles: {
          [key: string]: any;
      } = {}

      The styles to apply by default.

      • [key: string]: any

    Returns void

  • Trigger an event of a view field. The 'On'-prefix is not required for the event to be triggered.

    // Both will trigger the same event. The 'on'-prefix is not required.
    CSL.view.trigger(['Product Price'], 'blur');
    CSL.view.trigger(['Product Price'], 'onblur');

    Parameters

    • fieldNames: string[]

      The names of the fields to trigger the event on.

    • event: string

      The event to trigger.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Gets or sets the values of the view component. 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.view.values(); // Returns all values of the form
    CSL.view.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.view.values({'name': 'John'}, ['name', 'stock'], componentId); // Returns the values for 'name' and 'stock' after setting value for 'name'

    Parameters

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

    Returns any

Generated using TypeDoc