@adaptabletools/adaptable
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
184 lines (183 loc) • 6.64 kB
TypeScript
import { AdaptableColumn, ColumnSort, PivotLayout, TableLayout } from '../../types';
import { ExtendedLayoutInfo } from '../AdaptableState/Common/ExtendedLayoutInfo';
import { LayoutState, Layout } from '../AdaptableState/LayoutState';
/**
* Provides run-time access to the Layout Module and associated state
*/
export interface LayoutApi {
/**
* Retrieves Layout section from Adaptable State
*/
getLayoutState(): LayoutState;
/**
* Sets (i.e. selects) the Layout
* @param layoutName Layout to set (has to be name of existing Layout)
*/
setLayout(layoutName: string): void;
/**
* Retrieves Current Layout from Layout State
* @returns layout
*/
getCurrentLayout(): Layout;
/**
* Returns true if current Layout is a Pivot Layout
*/
isCurrentLayoutPivot(): boolean;
/**
* Retrieves the sort order of a column from the current layout
* @param columnId Column id
*/
getCurrentLayoutColumnSort(columnId: string): ColumnSort['SortOrder'] | null;
/**
* Retrieves map with visible columns in current Layout
*/
getCurrentVisibleColumnIdsMapForTableLayout(): {
[key: string]: boolean;
};
/**
* Retrieves array of visible ColumnIds in current Layout
*/
getCurrentVisibleColumnIdsForTableLayout(): string[];
/**
* Retrieves array of visible ColumnIds in current Layout
*/
getCurrentRowGroupsColumnIds(): string[];
/**
* Retrieves name of current Layout
*/
getCurrentLayoutName(): string;
/**
* Retrieves Layout with the given name
* @param layoutName Layout to retrieve
* @returns layout
*/
getLayoutByName(layoutName: string): Layout | null;
/**
* Retrieves Layout with the given name
* @param layoutName Layout to retrieve
* @returns layout
*/
getExtendedLayoutByName(layoutName: string): ExtendedLayoutInfo | undefined;
/**
* Retrieves all Layouts in Adaptable State
* @returns layouts
*/
getLayouts(): Layout[];
/**
* Retrieves Layout by by the technical ID (from `LayoutState`)
* @param id Layout id
* @returns layout
*/
getLayoutById(id: Layout['Uuid']): Layout;
/**
* Saves current Layout - using column order, visibility, sorting etc. currently in use in the grid
*/
saveCurrentLayout(): void;
/**
* Creates new Layout into Adaptable State or updates an existing Layout (with same name or id)
* @param layout the Layout to create or update
*/
createOrUpdateLayout(layout: Layout): void;
/**
* Updates current Layout using the partial Layout props provided in a function
* @param updateFn a function which returns a full Layout
*/
updateCurrentLayout(updateFn: (layout: TableLayout | PivotLayout) => TableLayout | PivotLayout): void;
/**
* Creates new Layout in Adaptable State
* @param layoutToCreate Layout to create
* @returns created Layout object or `false` if Layout with the same name/Uuid already exists
*/
createLayout(layoutToCreate: Layout): Layout | false;
/**
* Creates new Layout in the state and then loads it into Grid
* @param layoutToCreate Layout to create
* @returns created Layout object or `false` if creation failed
*/
createAndSetLayout(layoutToCreate: Layout): Layout | false;
/**
* Creates new Layout based on given Layout but with name provided
* @param layoutToClone Layout to clone
* @param layoutName name to use for new Layout
* @returns created Layout object or `false` if creation failed
*/
cloneLayout(layoutToClone: Layout, layoutName: string): Layout | false;
/**
* Creates new Layout based on given Layout but with name provided and then loads it into Grid
* @param layoutToClone Layout to clone
* @param layoutName name to use for new Layout
* @returns created Layout object or `false` if creation failed
*/
cloneAndSetLayout(layoutToClone: Layout, layoutName: string): Layout | false;
/**
* Checks whether this Layout exists in the Adaptable State (by comparing Uuid property)
* @param layout Layout to check
*/
doesLayoutExist(layout: Layout): boolean;
/**
* Opens Settings Panel with Layout section selected
*/
openLayoutSettingsPanel(): void;
/**
* Opens Layout Editor - for Current or a named Layout
* @param layoutName Name of Layout to be edited or cloned; if not specified, uses Current Layout
* @param action Whether to edit, clone, or create a new Layout
*/
showLayoutEditor(layoutName?: string, layoutType?: 'table' | 'pivot',
/**
* @defaultValue 'Edit'
*/
action?: 'New' | 'Clone' | 'Edit'): void;
/**
* Sets a new Caption / Header for a Column (only for current Layout)
* @param columnId Column to Update
* @param caption New Caption to display
*/
setColumnCaption(columnId: string, caption: string): void;
/**
* Deletes an existing Layout (if not Default or only existing Layout)
* @param layout The Layout to delete
*/
deleteLayout(layout: Layout): void;
/**
* Deletes an existing Layout provided by Name (if not Default or only existing Layout)
* @param layout Name of the Layout to delete
*/
deleteLayoutByName(layoutName: string): void;
/**
* Specifies where Current Layout is editable
*/
isCurrentLayoutReadOnly(): boolean;
/**
* Opens Change Column Caption popup
* @param column Column to open Popup for
*/
showChangeColumnCaption(column: AdaptableColumn): void;
/**
* Removes a Column from the Current Layout
* @param columnId Column to remove
*/
removeColumnFromCurrentLayout(columnId: string): void;
/**
* Removes a Column from all Layouts
* @param columnId Column to remove
*/
removeColumnFromAllLayouts(columnId: string): void;
/**
* Removes a Column from a given Layout
* @param columnId Column to remove
* @param layoutName layout from which to remove Column
*/
removeColumnFromLayout(columnId: string, layoutName: string): void;
/**
* Adds a Column to a given Table Layout
* @param columnId Column to add
* @param layoutName layout to which to add Column
*/
addColumnToTableLayout(columnId: string, layoutName: string): void;
/**
* Adds a Column to Current (Table) Layout
* @param columnId Column to add
*/
addColumnToCurrentTableLayout(columnId: string): void;
}