protected applyState()

in src/visualComponent/table/row/rowComponent.ts [411:477]


    protected applyState(state: IRowState): void {
        if (!this.options.stateService) {
            return;
        }

        if (!state || !state.cellSet || !state.cellSet[this.tableType]) {
            let width: number;
            let height: number;

            if (this.components
                && this.components[0] instanceof CellComponent
                && this.components[0].getState
            ) {
                const cellState: ICellState = (this.components[0] as CellComponent).getState();

                width = cellState.width;
                height = cellState.height;
            }

            const [widthReverted, heightReverted] = this.tableType === TableType.ColumnBasedKPIS
                ? [height, width]
                : [width, height];

            const currentWidth: number = this.tableType === TableType.ColumnBasedKPIS
                ? widthReverted
                : undefined;

            const currentHeight: number = this.tableType === TableType.RowBasedKPIS
                ? heightReverted
                : undefined;

            this.components.forEach((_, componentIndex: number) => {
                this.updateCellComponentSizeByIndex(currentWidth, currentHeight, componentIndex);
            });

            this.updateSize(width, height);

            this.updateSizeBasedOnChildren();

            return;
        }

        this.components.forEach((component: CellComponent, cellIndex: number) => {
            const cellState: ICellState = state.cellSet[this.tableType][cellIndex]
                || (this.components && this.components[0] && (this.components[0] as CellComponent).getState());

            if (cellState) {
                if (cellIndex === 0) {
                    let { width, height } = cellState;

                    if (this.tableType === TableType.ColumnBasedKPIS) {
                        [width, height] = [height, width];
                    }

                    this.updateSize(width, height);
                }

                this.updateCellComponentSizeByIndex(
                    cellState.width,
                    cellState.height,
                    cellIndex,
                );
            }
        });

        this.updateSizeBasedOnChildren();
    }