Class MultiRecordCustomScripting

This class supports the functionality for custom scripting on a multirecord view. You can access all the methods by using the namespace CSL.multiRecord.

Hierarchy

  • CslBase
    • MultiRecordCustomScripting

Properties

componentId: string = ''

The component id of the current view instance.

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

  • Deprecated

    Use CSL.multiRecord.undoChanges instead. @deletion-target 5.0.0 Undo all changes currently made. This will remove added rows, restore deleted rows and set original value on the updated cells.

    Parameters

    • Optional componentId: string

      The unique identifier of the component.

    Returns void

  • Sets the multi record view in the read only mode. A console message will be set if the view doesn't support inline editing. Or the view not in edit mode.

    Parameters

    • forceLeave: boolean = false

      Whether to close inline edit even when there unsaved changes. Default false.

    • Optional componentId: string

      The id of the multi record view.

      // Exit edit mode, but show confirmation dialog if there are any unsaved changes.
      CSL.multiRecord.closeInlineEditing();

      // Exit edit mode, even when there are unsaved changes.
      CSL.multiRecord.closeInlineEditing(true);

    Returns void

  • Triggers the delete function on the component for the given record.

    // Delete the record with rowKey (primary key) '3'
    CSL.multiRecord.deleteRecord('3');

    // Delete the fifth row.
    CSL.multiRecord.deleteRecord(5);

    Parameters

    • rowIdentifier: string | number

      The identifier of the row. If a number is passed, the x^tt^hh record will be deleted. If a string is passed, the record with the specified key will be deleted.

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns void

  • Deselects the given record(s).

    // Deselects row with primary key '458'
    CSL.multiRecord.deselect('458');
    // Deselects the second row.
    CSL.multiRecord.deselect(2);
    // Deselects the first and the row with primary key 87.
    CSL.multiRecord.deselect([1, '87']);

    Parameters

    • rowIdentifier: string | number | (string | number)[]

      The identifier of the row. If a number is passed, the x^tt^hh record will be deselected. If a string is passed, the record with the specified key will be deselected.

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns void

  • Deselects all the records.

    CSL.multiRecord.deselectAll();
    

    Parameters

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns void

  • Triggers the export functionality of the component.

    CSL.multiRecord.export();
    

    Parameters

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns void

  • Gets the value of a cell in a row. If you want to get the distinct values for a field in the current page, please use the getColumnValues method.

    // Get the value of stock from the row with primary key '33'.
    var stockValue = CSL.multiRecord.getCellValue('33', 'stock');

    // Get the value of productName from the second row.
    var productName = CSL.multiRecord.getCellValue(2, 'productName');

    Parameters

    • rowIdentifier: string | number

      The identifier of the row. If a number is passed, the x^tt^hh record will be taken. If a string is passed, the record with the specified key will be taken.

    • viewFieldName: string

      The name of the view field to get the value from.

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns any

  • Gets the distinct values for a view field in the current page of a multi record view.

    var stockValues = CSL.multiRecord.getColumnValues('stock');
    

    Parameters

    • viewFieldName: string

      The name of the view field.

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns any[]

  • Gets the data in the current page of the grid.

    var pageData = CSL.multiRecord.getPageData();
    

    Parameters

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns (DatabaseRow | DatabaseFormRow)[]

  • Gets an object containing the selected items. The keys in the object are the unique keys for a record, the values are the row values that correspond to the row key.

    var selectedItems = CSL.multiRecord.getSelectedItems();
    

    Parameters

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns ValueObject<any>

  • Whether the inline editing has pending changes.

    Parameters

    • Optional componentId: string

      The unique identifier of the component.

      const hasPendingChanges = CSL.multiRecord.hasPendingChanges();

      if (hasPendingChanges) {
      preventExecution('createFunction');
      }

    Returns any

  • Whether the component is in inline edit mode.

    Parameters

    • Optional componentId: string

      The unique identifier of the component.

      const isInEditMode = CSL.multiRecord.isInEditMode();

      if (isInEditMode) {
      alert('This component is in edit mode.');
      }

    Returns boolean

  • Gets the current mode of the grid.

    var gridMode = CSL.multiRecord.mode();
    

    Parameters

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns GridMode

  • Sets the multi record view in the inline editing mode. A console message will be set if the view doesn't support inline editing. Or the view is already in edit mode.

    Parameters

    • Optional componentId: string

      The id of the multi record view.

      CSL.multiRecord.openInlineEditing();
      

    Returns void

  • Shows or hides the progress indicator on the multi record view.

    // Starts progress
    CSL.multiRecord.progress();

    setTimeout(function() {
    // After 1.5s stop progress indication.
    CSL.multiRecord.progress(false);
    }, 1500);

    Parameters

    • processing: boolean = true

      Whether the progress indicator should be shown.

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns void

  • Sets the multi record view in the inline editing mode.

    Parameters

    • Optional componentId: string

      The id of the multi record view.

      CSL.multiRecord.saveInlineEditChanges();
      

    Returns void

  • Ensures that a certain row is selected.

    // Select the first row.
    CSL.multiRecord.select(1);
    // Select the row with primary key '87'
    CSL.multiRecord.select('87');
    // Select the second row and the row with primary key '33'
    CSL.multiRecord.select([2, '33']);

    Parameters

    • rowIdentifier: string | number | (string | number)[]

      The identifier of the row. If a number is passed, the x^tt^hh record will be selected. If a string is passed, the record with the specified key will be selected.

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns void

  • Selects all the rows on the current page.

    CSL.multiRecord.selectAll();
    

    Parameters

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns void

  • Sets the value for a cell.

    CSL.multiRecord.setCellValue('1', 'stock', 1750);
    

    Parameters

    • rowIdentifier: string | number
    • viewFieldName: string

      The name of the view field to update.

    • value: any

      The value to set.

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns void

  • Sets a condition on the styling of a field. This will execute the condition for each record in the set and apply the styles returned by the condition function. 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.

    // Set the productName and productDescription to a purple background and a white color.
    CSL.multiRecord.setFieldStyling(
    {'background-color': 'purple', 'color': 'white'},
    ['productName', 'productDescription']
    );

    // Sets the color for the productId and productDescription columns based on the productActive column.
    // If productActive = true, set the background to green with a white color. If false to red background. If the value
    // is unkown, the background will be blue.
    CSL.multiRecord.setFieldStyling((rowData) => {
    if (rowData.productActive === 'True') {
    // Object return example.
    return { 'background-color': 'green', color: 'white' };
    } else if (rowData.productActive === 'False') {
    // String return example.
    return 'background-color:red; color:black;';
    } else {
    return 'background-color:blue; color:white'
    }
    }, ['productId', 'productDescription']);

    Parameters

    • condition: ValueObject<string> | ((rowData: any, index: any) => string | ValueObject<string>)

      The condition of the styling to set.

    • fieldNames: string | string[]

      The names of the field that will be affected.

    • Optional componentId: string

      The id of the multi record view.

    • skipFieldValidation: boolean = false

      Whether validation of the existence of a field should be skipped. Set this to true when dynamically generating view fields.

    Returns void

  • Sets a condition on the styling of a header. 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.multiRecord.setHeaderStyling((dataSet) => {
    // Find a record where productActive is 'False'.
    const inActive = dataSet.find(d => d.productActive === 'False');

    // Set background-color based on whether there’s a record with productActive set to 'False'.
    if (inActive) {
    return 'background:#FF8977';
    } else {
    return { 'background-color': '#C3FFA6' };
    }
    }, ['productActive']);

    Parameters

    • condition: ValueObject<String> | ((dataBase: any, index: any) => string | ValueObject<string>)

      The condition function to execute for each row.

    • fieldNames: string | string[]

      The names of the fields that will be affected.

    • Optional componentId: string

      The unique identifier of the multi record view.

    • skipFieldValidation: boolean = false

      Whether validation of the existence of a field should be skipped. Set this to true when dynamically generating view fields.

    Returns void

  • Sets the styling of a group row. 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.

    // If the group contains the name 'John', make background purple. Else set it to orange.
    CSL.multiRecord.setRecordGroupStyling((groupRows, groupData) => {
    // Get all the names of the persons
    const names = groupData.map((person) => person.name);
    // Check if the array contains a 'John'
    const hasJohn = names.includes('John');

    if (hasJohn) {
    return 'background-color:purple'
    } else {
    return 'background-color:orange'
    }
    });

    Parameters

    • condition: ValueObject<String> | ((rowData: DatabaseRow[], groupData: ValueObject<any>[]) => string | ValueObject<string>)

      The condition function to execute for each row.

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns void

  • Sets the styling of a row. 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.

    // Set the record styling to a purple background and a white color.
    CSL.multiRecord.setRecordStyling({ background: 'purple', color: 'white' });

    // Sets the record styling based on a condition.
    CSL.multiRecord.setRecordStyling((rowData) => {
    if (rowData['productActive'] === 'True') {
    // Object return example.
    return { 'background-color': 'green', color: 'white' };
    } else if (rowData['productActive'] === 'False') {
    // String return example.
    return 'background-color:red; color:black; font-size:20px';
    } else {
    return 'background-color:black; color:white';
    }
    });

    Parameters

    • condition: ValueObject<String> | ((rowData: any, index: any) => string | ValueObject<string>)

      The condition function to execute for each row.

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns void

  • Set a condition to enable the selection of certain records. The condition will be executed for each record in the current page. If the condition function returns true, a row is selectable.

    // Only make records selectable where the First Name starts with the capital letter J.
    CSL.multiRecord.setSelectionCondition(rowData => rowData['First Name'].indexOf('J') === 0);

    Parameters

    • condition: Function

      The condition function to execute. The first parameter is the row data of the current row that the condition is executed for.

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns void

  • Undo all changes currently made. This will remove added rows, restore deleted rows and set original value on the updated cells.

    Parameters

    • Optional componentId: string

      The unique identifier of the component.

      CSL.multiRecord.undoChanges();
      

    Returns void

Generated using TypeDoc