@adaptabletools/adaptable
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
97 lines (96 loc) • 2.89 kB
TypeScript
import { IRowNode } from 'ag-grid-enterprise';
import { RowScope } from '../AdaptableState/Common/RowScope';
import { AdaptableButton, AdaptableObject, BaseContext } from '../types';
/**
* 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> extends AdaptableObject {
/**
* 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; if unset, calculated dynamically by AG Grid
*/
width?: number;
/**
* 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';