ActiveUI

ActiveUI

  • User Guide
  • Developer Documentation

Home > @activeviam/activeui-sdk > useSelectedPage

useSelectedPage() function

A React hook that provides the API and index of the active page of the currently selected dashboard.

Signature:

export declare function useSelectedPage(): SelectedPageProps;

Returns:

SelectedPageProps

Example

// Custom button to add an unconfigured Pivot Table to the active page of the selected dashboard
// The bookmark content should be adapted. This is just an example.

const unconfiguredPivotTableBookmark = {
  type: 'container',
  value: {
    body: {
      tabular: {
        hideAddButton: true,
        lineNumbers: true,
        statisticsShown: true,
      },
    },
    containerKey: 'pivot-table',
    showTitleBar: true,
  },
};

function AddPivotTableButton() {
  const {selectedPageApi} = useSelectedPage();
  return (
    <button
      onClick={() => {
        selectedPageApi.loadBookmarkRelativeTo(
          unconfiguredPivotTableBookmark,
          0,
          'right',
        );
      }}
    >
      Add Pivot Table
    </button>
  );
}

  • useSelectedPage() function
  • Example
Copyright © 2023 ActiveViam