Tableau Extensions API
    Preparing search index...

    Interface Sheet

    Interface for handling registering and unregistering event listeners. Different objects will implement this interface to manage their event handling.

    interface Sheet {
        name: string;
        sheetType: SheetType;
        size: Size;
        addEventListener(
            eventType: TableauEventType,
            handler: TableauEventHandlerFn,
        ): TableauEventUnregisterFn;
        findParameterAsync(parameterName: string): Promise<undefined | Parameter>;
        getParametersAsync(): Promise<Parameter[]>;
        removeEventListener(
            eventType: TableauEventType,
            handler: TableauEventHandlerFn,
        ): boolean;
    }

    Hierarchy (View Summary)

    Index

    Properties

    name: string

    The name of the sheet.

    sheetType: SheetType

    The type of the sheet.

    size: Size

    Size of the sheet.

    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();
    • Searches for a parameter with the given name.

      Parameters

      • parameterName: string

        The name of the parameter to find.

      Returns Promise<undefined | Parameter>

      The parameter with the given name, or undefined if it does not exist.

    • Returns Promise<Parameter[]>

      A collection of all the Tableau parameters that are used in this workbook.

    • 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.