UNPKG

@catull/igniteui-angular

Version:

Ignite UI for Angular is a dependency-free Angular toolkit for building modern web apps

168 lines (167 loc) 5.78 kB
import { ComponentFactoryResolver, ViewContainerRef } from '@angular/core'; import { ISortingExpression } from '../data-operations/sorting-expression.interface'; import { IFilteringExpressionsTree } from '../data-operations/filtering-expressions-tree'; import { IPagingState } from '../data-operations/paging-state.interface'; import { DataType } from '../data-operations/data-util'; import { GridSelectionRange } from './selection/selection.service'; import { IGroupingState } from '../data-operations/groupby-state.interface'; import { IgxGridComponent } from './grid/grid.component'; export interface IGridState { columns?: IColumnState[]; filtering?: IFilteringExpressionsTree; advancedFiltering?: IFilteringExpressionsTree; paging?: IPagingState; sorting?: ISortingExpression[]; groupBy?: IGroupingState; cellSelection?: GridSelectionRange[]; rowSelection?: any[]; } export interface IGridStateOptions { columns?: boolean; filtering?: boolean; advancedFiltering?: boolean; sorting?: boolean; groupBy?: boolean; paging?: boolean; cellSelection?: boolean; rowSelection?: boolean; } export interface IColumnState { pinned: boolean; sortable: boolean; filterable: boolean; editable: boolean; sortingIgnoreCase: boolean; filteringIgnoreCase: boolean; headerClasses: string; headerGroupClasses: string; maxWidth: string; groupable: boolean; movable: boolean; hidden: boolean; dataType: DataType; hasSummary: boolean; field: string; width: any; header: string; resizable: boolean; searchable: boolean; } export declare class IgxGridStateDirective { private grid; private resolver; protected viewRef: ViewContainerRef; private _options; private state; /** * An object with options determining if a certain feature state should be saved. * * ```html * <igx-grid [igxGridState]="options"></igx-grid> * ``` * ```typescript * public options = {selection: false, advancedFiltering: false}; * ``` */ options: IGridStateOptions; /** * @hidden */ constructor(grid: IgxGridComponent, resolver: ComponentFactoryResolver, viewRef: ViewContainerRef); /** * Gets the state of a feature or states of all grid features, unless a certain feature is disabled through the `options` property. * @param `serialize` determines whether the returned object will be serialized to JSON string. Default value is false. * @param `feature` string or array of strings determining the features which state to retrieve. If skipped, returns all. * @returns Returns the serialized to JSON string IGridState object, or the non-serialized IGridState object. * ```html * <igx-grid [igxGridState]="options"></igx-grid> * ``` * ```typescript * @ViewChild(IgxGridStateDirective, { static: true }) public state; * let state = this.state.getState(); * ``` */ getState(serialize?: boolean, feature?: string | string[]): IGridState | string; /** * Restores grid features' state based on the IGridState object passed as an argument. * @param IGridState object to restore state from. * @returns * ```html * <igx-grid [igxGridState]="options"></igx-grid> * ``` * ```typescript * @ViewChild(IgxGridStateDirective, { static: true }) public state; * this.state.setState(gridState); * ``` */ setState(state: IGridState | string): void; /** * The method that calls corresponding methods to restore feature from this.state object. */ private restoreGridState; /** * Restores the state of a feature. */ private restoreFeature; /** * Returns an object containing all grid features state. */ private getAllGridFeatures; /** * Restores an object containing the state for a grid feature. * `serialize` param determines whether the returned object will be serialized to a JSON string. Default value is false., */ private getGridFeature; /** * Helper method that creates a new array with the current grid columns. */ private getColumns; private getFiltering; private getAdvancedFiltering; private getPaging; private getSorting; private getGroupBy; private getRowSelection; private getCellSelection; /** * Restores the grid columns by modifying the `columnList` collection of the grid. */ private restoreColumns; private sortByVisibleIndex; /** * Restores the grid filtering state, i.e. sets the `filteringExpressionsTree` property value. */ private restoreFiltering; /** * Restores the grid advanced filtering state, i.e. sets the `advancedFilteringExpressionsTree` property value. */ private restoreAdvancedFiltering; /** * Restores the grid sorting state, i.e. sets the `sortingExpressions` property value. */ private restoreSorting; /** * Restores the grid grouping state, i.e. sets the `groupbyExpressions` property value. */ private restoreGroupBy; /** * Restores the grid paging state, i.e. sets the `perPage` property value and paginate to index. */ private restorePaging; private restoreRowSelection; private restoreCellSelection; /** * This method builds a FilteringExpressionsTree from a provided object. */ private createExpressionsTreeFromObject; /** * Returns the filtering logic function for a given dataType and condition (contains, greaterThan, etc.) */ private generateFilteringCondition; private stringifyCallback; } /** * @hidden */ export declare class IgxGridStateModule { }