Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Settings

The settings namespace is used to get and set settings values. You can use the settings to configure your extension. The setting values are be persisted in a workbook.

Hierarchy

Index

Properties

isModified

isModified: boolean

Indicates whether or not the settings have been modified since the last call to saveAsync.

returns

True if settings have been modified, false otherwise.

Methods

addEventListener

  • Adds a new event listener to the object. If this object does not support the specified eventType, the method throws an exception. Note that you can't add an event listener to a dashboard. This is because the Dashboard object does not support any event types, even though the Dashboard object inherits the event listener methods from EventListenerManager. For more information, see Events and Event Handling. The following table shows the event types supported by objects.

    object eventType
    Worksheet FilterChanged , MarkSelectionChanged
    Parameter ParameterChanged
    Settings SettingsChanged
    Dashboard None available

    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();
    

erase

  • erase(key: string): void
  • Erases a settings key / value pair. If key isn't found, nothing happens.

    Parameters

    • key: string

      The key of the pair to erase.

    Returns void

get

  • get(key: string): string | undefined
  • Gets a settings value or undefined if the value does not exist.

    Parameters

    • key: string

      The key to retrieve.

    Returns string | undefined

    The value or undefined if it does not exist.

getAll

  • getAll(): object
  • Returns a copy of all the saved settings keys and values. Modifying this value will have no effect on the class.

    Returns object

    All the saved settings keys and values in a dictionary.

    • [key: string]: string

removeEventListener

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

saveAsync

  • saveAsync(): Promise<object>
  • Attempts to persist any currently modified settings key-value pairs. The saveAsync() method should only be called in authoring mode.

    Returns Promise<object>

    Promise containing the newly saved settings values.

    tableau.extensions.settings.saveAsync().then(result => {
       console.log('Settings saved.');
       // ... process results
    }).catch((error) => {
      // ...
      // ... code for error handling
    });
    

set

  • set(key: string, value: string): void
  • Adds or updates a settings key / value pair.

    Parameters

    • key: string

      The key to save.

    • value: string

      The value to save.

    Returns void