UNPKG

@true-directive/base

Version:

The set of base classes for the TrueDirective Grid

185 lines (184 loc) 6.99 kB
import { DataSource } from './classes/data-source.class'; import { Summary, SummaryType } from './classes/summary.class'; import { SortInfo } from './classes/sort-info.class'; import { PageInfo } from './classes/page-info.class'; import { Column } from './classes/column.class'; import { ColumnBand } from './classes/column-band.class'; import { ColumnCollection } from './classes/column-collection.class'; import { Filter } from './classes/filter.class'; import { DataQuery } from './classes/data-query.class'; import { CellPosition } from './classes/cell-position.class'; import { Selection } from './classes/selection.class'; import { GridAppearance } from './classes/grid-appearance.class'; import { GridLayout } from './classes/grid-layout.class'; import { GridExporter } from './classes/grid-exporter.class'; import { AxInjectConsumer } from './classes/ax-inject-consumer.class'; import { GridSettings } from './classes/grid-settings.class'; import { GridUIHandler } from './handlers/grid-ui.handler'; import { GridCheckHandler } from './handlers/grid-check.handler'; import { GridDragHandler } from './handlers/grid-drag.handler'; import { GridLazyLoadHandler } from './handlers/grid-lazy-load.handler'; import { LayoutsHandler } from './handlers/layouts.handler'; import { IEvents } from './events.interface'; /** * Grid's state. Contains: * - grid's settings * - provided column's list * - column's lists for every part of the grid (only main area in the current version) * - sorting info * - drag-n-drop state * - current page info * Receives changes of the state and provides it for all parts. */ export declare abstract class GridState extends AxInjectConsumer { dataSource: DataSource; selection: Selection; check: GridCheckHandler; dragDrop: GridDragHandler; ui: GridUIHandler; lazyLoader: GridLazyLoadHandler; events: IEvents; layoutsHandler: LayoutsHandler; /** * Список колонок */ columnCollection: ColumnCollection; /** * Grid's settings. * Будет создано. Но можем и поменять. Если меняем - обновляем в хэндлерах. */ private _settings; settings: GridSettings; readonly st: GridSettings; readonly ds: DataSource; readonly sta: GridAppearance; /** * Данные грида */ model: any[]; columns: Column[]; readonly layout: GridLayout; readonly layoutDrag: GridLayout; IE: boolean; iOS: boolean; android: boolean; safari: boolean; pageInfo: PageInfo; showFixedLeft: boolean; showFixedRight: boolean; /** * Gets column by field name * @param f Field name * @return Column if exists */ columnByFieldName(f: string): Column; /** * Отображать ли данные в виде дерева */ readonly isTree: boolean; /** * Уровень вложенности - ноль */ readonly maxLevel: number; /** * The width of viewport's visible area. * This property is used for column's width calculation * with setting columnAutoWidth=true. */ private _clientWidth; readonly clientWidth: number; private _clientHeight; readonly clientHeight: number; /** * The list of grid parts */ readonly layouts: Array<GridLayout>; /** * The device supporting touch events is used. */ readonly touchMode: boolean; /** * Index of the first row is displayed according to current scroll position. */ private _displayedStartIndex; displayedStartIndex: number; /** * Data query counter */ protected _dataQueryCounter: number; checkClientWidth(v: number): boolean; checkClientHeight(v: number): boolean; /** * Recalculation of rows in accordance with the specified filters, * sorting and other. */ protected recalcData(): Promise<void>; getQuery(subject?: any): DataQuery; /** * Request data from an observer. * @param counter Query counter value * @param subject Observer */ protected doQuery(subject?: any, force?: boolean): void; /** * Initiation of data update with all recalculations. * @param async Recalculation in the asynchronous thread. */ updateData(async?: boolean): void; fetchData(query: DataQuery, data?: any[], totalRowCount?: number): void; protected queryChanged(): void; clearSelection(): void; updateLayouts(): void; protected resizeLayouts(): void; showFilter(e: any, c: Column): void; setFilter(f: Filter): void; resetFilter(f: Filter): void; /** * Data sorting * @param sortings List of sortings */ sort(sortings: SortInfo[], update?: boolean): void; /** * Data filtering * @param filter List of filters */ filter(filters: Filter[], update?: boolean): void; /** * Sort by given column * @param col Column * @param add Если true, то оставляем предыдущую сортировку (с зажатым shift) */ sortByColumn(col: Column, add: boolean): void; /** * Сортировать по полю * @param fieldName Наименование поля * @param add Добавить сортировку к другим сортировкам */ sortByField(fieldName: string, add: boolean): void; resizeColumn(col: Column, newWidth: number): void; hideColumn(col: Column): void; fixDrag(target: Column): void; reorderBand(targetBand: ColumnBand, dropInfo: any): void; reorderColumn(target: Column, dropInfo: any, commit?: boolean): void; needSetPage(i0: number, i1: number): boolean; setPage(offset: number, limit: number): void; protected focusChanged(cp: CellPosition): void; selectRow(r: any, ri: number): CellPosition; locateRow(r: any): boolean; locateByKey(keyValue: any, keyField?: string): boolean; headerContextMenu(e: any, column: Column): void; updateSummaries(): void; addSummary(column: Column, t: SummaryType): void; setSummary(column: Column, t: SummaryType, a?: Summary): void; canDrop(draggedRows: any[], dropRow: any, dropPos: string): string; moveRows(draggedRows: any[], dropTarget: any, dropPos: string): void; protected headerContextMenuEvent(e: any, column: Column): void; getSelectedData(selection: Selection): GridExporter; selectAll(sel: Selection): Selection; dataToExport(): GridExporter; emitCustomCellEvent(e: any): void; abstract copySelectionToClipboard(withColumns: boolean): void; abstract exportToCSV(fileName: string): void; protected registerHandlers(): void; constructor(); }