@adaptabletools/adaptable
Version:
Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
123 lines (122 loc) • 3.87 kB
TypeScript
import { IRowNode } from 'ag-grid-enterprise';
import { RowScope } from '../AdaptableState/Common/RowScope';
import { AdaptableButton, BaseContext } from '../types';
/**
* How action column buttons are laid out in the cell
*/
export type ActionColumnDisplayMode = 'buttons' | 'dropdown';
/**
* Options related to Action Columns in AdapTable
*/
export interface ActionColumnOptions<TData = any> {
/**
* Columns which contain an AdapTable Button - used for performing Actions
* @defaultValue undefined
*/
actionColumns?: ActionColumn<TData>[];
}
/**
* A Special Column that wraps an AdapTable Button
*/
export interface ActionColumn<TData = any> {
/**
* Mandatory 'Id'; if no value set for `FriendlyName`, this will also be Column name
*/
columnId: string;
/**
* How Column appears in Column Header, Menus; if no value set, `ColumnId` is used
*/
friendlyName?: string;
/**
* Button (or list of buttons) to display in the Column
*/
actionColumnButton: ActionColumnButton<ActionColumnContext<TData>> | ActionColumnButton<ActionColumnContext<TData>>[];
/**
* Which types of Rows should contain buttons (i.e. data, grouped, summary)
*/
rowScope?: RowScope;
/**
* Optional properties to configure the Column (e.g. filterable, resizable)
*/
actionColumnSettings?: ActionColumnSettings;
}
/**
* Context required by functions when using an Action Column Button
*/
export interface ActionColumnContext<TData = any> extends BaseContext {
/**
* Action Column in question
*/
actionColumn: ActionColumn<TData>;
/**
* Primary Key Value in current row
*/
primaryKeyValue: any;
/**
* Current AG Grid Row Node
*/
rowNode: IRowNode<TData>;
/**
* The current row's data
*/
data: TData;
}
/**
* Set of optional properties that define an Action Columns behaviour
*/
export interface ActionColumnSettings {
/**
* Preferred width (in pixels) for Column; takes precedence over `autoWidth` and `minWidth`
*/
width?: number;
/**
* Minimum width (in pixels) for the column; also used as the column width when `autoWidth` is false
*/
minWidth?: number;
/**
* When true, estimates column width from button labels/icons (or dropdown label) at setup time.
* Dynamic labels and icons (functions) are not measured — set `width` explicitly in those cases.
* @defaultValue false
*/
autoWidth?: boolean;
/**
* How buttons are rendered in the column.
* In `'dropdown'` mode, per-button `buttonStyle` and `iconPosition` are ignored;
* the trigger uses fixed styling and menu items use the standard list layout (icon, then label).
* @defaultValue 'buttons'
*/
displayMode?: ActionColumnDisplayMode;
/**
* Label on the dropdown trigger when `displayMode` is `'dropdown'`
* @defaultValue 'Actions'
*/
dropdownLabel?: string;
/**
* Whether Column can be resized (by dragging column header edges)
* @defaultValue true
*/
resizable?: boolean;
/**
* Whether no menu should be shown for this Column header.
* @defaultValue false
*/
suppressMenu?: boolean;
/**
* Whether if this Column should be movable via dragging
* @defaultValue false
*/
suppressMovable?: boolean;
}
/**
* Button that is displayed inside an Action Column
*/
export interface ActionColumnButton<T> extends AdaptableButton<ActionColumnContext<T>> {
/**
* Command to assign to Action Column Button that displays a Row Form
*/
command?: ActionButtonCommand;
}
/**
* Commands to assign to Action Buttons that open Row Forms: 'create', 'clone', 'edit' or 'delete'
*/
export type ActionButtonCommand = 'create' | 'clone' | 'edit' | 'delete';