Tableau Extensions API
    Preparing search index...

    Interface Parameter

    Represents a parameter in Tableau and provides ways to introspect the parameter and change its values.

    interface Parameter {
        allowableValues: ParameterDomainRestriction;
        currentValue: DataValue;
        dataType: DataType;
        id: string;
        name: string;
        addEventListener(
            eventType: TableauEventType,
            handler: TableauEventHandlerFn,
        ): TableauEventUnregisterFn;
        changeValueAsync(
            newValue: string | number | boolean | Date,
        ): Promise<DataValue>;
        removeEventListener(
            eventType: TableauEventType,
            handler: TableauEventHandlerFn,
        ): boolean;
    }

    Hierarchy (View Summary)

    Index

    Properties

    The allowable set of values this parameter can take.

    currentValue: DataValue

    DataValue representing the current value of the parameter.

    dataType: DataType

    The type of data this parameter holds.

    id: string

    A unique identifier for this Parameter.

    name: string

    The display name of this parameter.

    Methods

    • Adds a new event listener to the object. If this object does not support the specified eventType, the method throws an exception. The following table shows the event types supported by objects.

      object eventType
      Worksheet FilterChanged , MarkSelectionChanged, SummaryDataChanged, WorksheetFormattingChanged
      Parameter ParameterChanged
      Settings SettingsChanged
      Dashboard DashboardLayoutChanged, WorkbookFormattingChanged

      Parameters

      • eventType: TableauEventType

        The type of event to register for. The type of event is a TableauEventType enumeration.

      • handler: TableauEventHandlerFn

        The function which will be called when an event happens.

      Returns TableauEventUnregisterFn

      A helper function which can be called to remove this registration.

      The following example sets up a listener in a worksheet for a mark selection event (MarkSelectionChanged). When the event occurs, the data is reloaded. The addEventListener method returns a function that un-registers the event handler. Call that function, in this case, unregisterEventHandlerFunction() to remove the registration.

      // Add an event listener for the selection changed event on this sheet.
      // Assigning the event to a variable just to make the example fit on the page here.
      const markSelection = tableau.TableauEventType.MarkSelectionChanged;
      //
      unregisterEventHandlerFunction = worksheet.addEventListener(markSelection, function (selectionEvent) {
      // When the selection changes, reload the data
      loadSelectedMarks(worksheetName);
      });

      // remove the event listener when done
      unregisterEventHandlerFunction();
    • Modifies this parameter and assigns it a new value. The new value must fall within the domain restrictions defined by allowableValues. If the domain restriction is ParameterValueType.Range, be sure to check the allowableValues before assigning a new value. If the new value is out of range, the updated value will be set to either the minValue or the maxValue of the allowable range. If a step size is also specified and the new value does not fall on the step intervals, the updated value will be set to the closest, lower step, or closest, earlier date. If the domain restriction is type ParameterValueType.List, and there are aliases defined for the list, the aliased value should be passed to the method.

      Parameters

      • newValue: string | number | boolean | Date

        The new value to assign to this parameter.

        Note

        For changing Date parameters, UTC Date objects are expected.

      Returns Promise<DataValue>

      The updated DataValue. The promise is rejected if newValue is invalid. However, if the domain restriction is type AllowableValuesType.Range, and the newValue is out of the range bounds, the parameter gets set to the minValue or the maxValue of the range (whichever is closer). If the range has a stepSize or dateStepPeriod, the parameter gets set to the closest, lower step, or the closest, earlier date.

    • Removes an event listener if a matching one is found. If no matching listener exists, the method does nothing. The handler function must the handler function specified in the call to the addEventListener method. Alternatively, use the function returned from the call to addEventListener to unregister the event listener. For more information, see Events and Event Handling.

      Parameters

      Returns boolean

      Whether or not an event listener was removed.