UNPKG

@true-directive/grid

Version:

Angular Data Grid from Yopsilon.

286 lines (285 loc) 11.7 kB
/** * Copyright (c) 2018-2019 Aleksey Melnikov, True Directive Company. * @link https://truedirective.com/ * @license MIT */ import { ElementRef, QueryList, ChangeDetectorRef, KeyValueDiffers, EventEmitter, DoCheck, OnDestroy } from '@angular/core'; import { Subject, Observable } from 'rxjs'; import { GridPart } from '@true-directive/base'; import { Column, CellPosition, GridSettings, RowLayout, DataQuery, UIAction, SortInfo, Filter, Selection } from '@true-directive/base'; import { RowCalculator } from '@true-directive/base'; import { ScrollerComponent } from './scroller.component'; import { BaseComponent } from './base.component'; import { RowDirective } from './row.directive'; import { GridStateService } from './grid-state.service'; import { InternationalizationService } from './internationalization/internationalization.service'; import { FilterPopupComponent } from './filters/filter-popup.component'; import { MenuStarterComponent } from './controls/menu-starter.component'; export declare class GridViewComponent extends BaseComponent implements DoCheck, OnDestroy { state: GridStateService; protected intl: InternationalizationService; protected elementRef: ElementRef; protected changeDetector: ChangeDetectorRef; protected keyValueDiffers: KeyValueDiffers; protected destroy$: Subject<boolean>; private _data; private _dataSubscription; /** * Grid data source. You can specify an observable object or array. */ /** * Data source * @return Array of the rows or observable object */ data: any[] | Observable<any[]>; /** * List of the rows to display * @return Array of the rows */ readonly rows: any[]; /** * Resulting list of rows after applying filters and sorting * @return Array of the rows */ readonly resultRows: any[]; /** * Current locale name */ readonly locale: string; /** * List of the columns */ columns: Column[]; /** * Grid's settings */ settings: GridSettings; /** * The maximum grid height, unless explicitly specified. */ maxHeight: number; /** * Text search data for all columns */ searchString: string; /** * Event that will be triggered when data retrieval options are changed (filters, * sortings) * @param 'dataQuery' [description] * @return [description] */ dataQuery: EventEmitter<DataQuery>; queryChanged: EventEmitter<DataQuery>; startProcess: EventEmitter<string>; endProcess: EventEmitter<string>; headerContextMenu: EventEmitter<any>; customCellEvent: EventEmitter<any>; menuAction: EventEmitter<any>; menuStarter: MenuStarterComponent; filterPopup: FilterPopupComponent; scroller: ScrollerComponent; grid: any; gridHeader: any; gridData: any; dragItem: any; displayedRows_template: QueryList<RowDirective>; displayedRowsCenter: QueryList<RowDirective>; customTemplate: any; protected uiAction: UIAction; protected _initialized: boolean; private _viewInitialized; private _lastUpdateTime; protected readonly _lastScroll: { pos: number; renderedPos: number; time: number; }; dataUpdating: boolean; readonly displayedRows: QueryList<RowDirective>; protected need_recalc_page: boolean; private _prevOffset; private _prevLimit; /** * Current appearance css-class */ private _currentAppearance; /** * List of rows to be rendered. */ private _currentRendered; private _settingsDiffer; private _appearanceDiffer; viewPortLeft: number; viewPortWidth: number; RC: RowCalculator; readonly selection: Selection; protected _headerParts(): BaseComponent[]; protected readonly headerParts: BaseComponent[]; protected _dataParts(): Array<QueryList<RowDirective>>; protected readonly dataParts: Array<QueryList<RowDirective>>; immediateFilter(filter: string): void; /** * List of the rows to render * @return Array of the rows */ readonly visibleRows: any[]; private saveRowHeights; /** * Page refresh * @param forceChanges Force update even if there was no scrolling * @param overwork The number of rows that will be rendered outside the viewport */ updatePage(log?: string, forceChanges?: boolean, overwork?: any): void; /** * Force view update */ updateView(): void; cellPosition(row: any, fieldName: string): CellPosition; startSelect(cp: CellPosition, add?: boolean): void; proceedToSelect(cp: CellPosition): void; /** * Hide all buttons in column headers */ hideHeaderBtns(): void; /** * Asynchronous data update. The Observable returns, by subscribing to which * you can find out when this update ended. * Use this method with lazy loading settings. * @param data The data (array of objects). * @return Observable object whose event will occur immediately after processing. */ updateDataAsync(data: any[]): Observable<any>; /** * Updating data with external or internal change. */ updateData(async?: boolean): void; updateSummaries(): void; /** * Received data externally (from the parent component) * @param query The request in response to which the data received. * @param data Data that received in response to a given request. */ fetchData(query: DataQuery, data: any[], totalRowCount?: number): void; protected renderData(): void; private _inProcess; protected updatePageByScroll(): void; /** * Scrolling data * @param e Scroll event */ gridScroll(e: any): void; /** * Triggered by automatic scrolling during area selection * @param dx How many pixels are scrolled horizontally? */ gridAutoScrollX(dx: number): void; /** * We need call this method for the changes to take effect. * If dataAffected=true then re-filter and re-sort data. * @param log Reason for detecting changes * @param dataAffected Is the data changed */ detectChanges(log?: string, dataAffected?: boolean): void; protected displayedRowsByXY(x: number, y: number, place?: GridPart): QueryList<RowDirective>; protected rowLayouts(rows: QueryList<RowDirective>): RowLayout[]; protected rowByXY(rows: QueryList<RowDirective>, x: number, y: number): RowLayout; protected cellByXY(x: number, y: number, place?: GridPart): CellPosition; protected refreshSelection(scrollTo: CellPosition): void; /** * Прокрутить скроллбоксы так, чтобы была видна ячейка, на которой находится * виртуальный фокус */ scrollToFocused(): void; /** * Прокрутка к указанной ячейке. * Обычно вызываем после обработки нажатия клавиши, чтобы была видна строка * с фокусом. * Также вызывается после клика мышью по ячейке.. Если ячейка видна на экране * только частично - немного скроллим. * @param cellPos Позиция ячейки, к которой прокручиваем грид */ scrollTo(cellPos: CellPosition): void; scrollToTop(): void; protected toggleClass(v: boolean, c: string): void; /** * Проверить, нужно ли отобразить левую или правую область для зафиксированных * колонок * @param xx [description] * @param scrollRect [description] * @param target [description] * @return [description] */ protected checkParts(xx: number, scrollRect: any, target: any): void; /** * Выделение заданной строки * @param r Заданная строка * @return Найдена ли заданная строка в списке отображаемых строк */ locateRow(r: any): boolean; /** * Выделение строки по заданному значению ключевого поля * @param keyValue Значение ключевого поля * @param keyField Ключевое поле. Если не задано, то поле берется из settings * @return Найдена ли строка с заданным ключом */ locateByKey(keyValue: any, keyField?: string): void; /** * Очистка выделения */ clearSelection(): void; /** * Трек отображаемых записей для более быстрого рендера ангуляром * @param index Индекс строки * @param data Данные строки */ trackRow(index: number, data: any): any; /** * При изменении размеров окна вызывается этот метод. * Если размер компонента изменяется какими-то действиями пользователя помимо * изменения размеров окна браузера (вьюпорта), то необходимо вызывать этот * метод. * Этот метод также следует вызывать при drop колонки, т.к. размер центральной * области меняется, если колонка переброшена в левую или правую фиксированную * область. * @param update_page=false [description] * @return [description] */ checkSize(update_page?: boolean): boolean; protected windowResize(e: any): void; /** * Показать кнопку заголовка для колонки по заданному полю * @param fieldName Заданное поле */ showHeaderBtn(fieldName: string): void; /** * Data sorting * @param sortings List of sortings */ sort(sortings: SortInfo[], update?: boolean): void; clearSorting(update?: boolean): void; /** * Data filtering */ filter(filters: Filter[], update?: boolean): void; filterToString(filter: Filter): string; filterClosed(result: any): void; setFilter(f: any): void; resetFilter(f: any): void; protected getFilterComponentType(filter: Filter): any; protected showFilter(e: any): void; focus(): void; protected readonly appearanceClass: string; /** * Установка класса внешнего вида * @param appearanceClass Класс, который будет применен к компоненту */ setAppearance(): void; menuItemClick(e: any): void; ngOnInit(): void; ngAfterContentInit(): void; ngAfterViewInit(): void; protected doCheckParts(): void; ngDoCheck(): void; ngOnDestroy(): void; constructor(state: GridStateService, intl: InternationalizationService, elementRef: ElementRef, changeDetector: ChangeDetectorRef, keyValueDiffers: KeyValueDiffers); }