맥스그리드 API 레퍼런스
    Preparing search index...

    Interface GridHooks<TRow>

    GridOptions.hooks: 취소 가능한 훅. 예외는 허용으로 보고 error 이벤트(callback-error)로 알린다.

    interface GridHooks<TRow = unknown> {
        beforeAddRows?: (
            ctx: { rows: TRow[]; source: "keyboard" | "api" },
        ) => boolean | void;
        beforeCellsDrag?: (ctx: { range: CellRange }) => boolean | void;
        beforeCellsDrop?: (
            ctx: {
                from: CellRange;
                mode: "move" | "copy";
                to: CellRange;
                values: unknown[][];
            },
        ) => boolean
        | void;
        beforeChartCreate?: (
            ctx: {
                data: ChartData;
                source: "selection" | "visible" | "all" | "columns";
                type: ChartType;
            },
        ) => boolean
        | void;
        beforeCollapse?: (
            ctx: {
                keys: RowKey[] | "all";
                kind: "group" | "tree";
                source: "api" | "user";
            },
        ) => boolean
        | void;
        beforeColumnChange?: (
            ctx: {
                columnId: string;
                type:
                    | "hide"
                    | "move"
                    | "add"
                    | "remove"
                    | "show"
                    | "pin"
                    | "unpin"
                    | "resize"
                    | "update";
            },
        ) => boolean
        | void;
        beforeContextMenu?: (
            ctx: {
                columnId: string | null;
                event: MouseEvent | null;
                rowKey: RowKey | null;
                zone: ContextMenuZone;
            },
        ) => boolean
        | void;
        beforeCopy?: (
            ctx: { columns: string[]; headers: boolean; rows: number },
        ) => boolean | void;
        beforeCut?: (
            ctx: { columns: string[]; headers: boolean; rows: number },
        ) => boolean | void;
        beforeEdit?: (
            ctx: {
                columnId: string;
                rowKey: RowKey;
                trigger: CellEditTrigger;
                value: unknown;
            },
        ) => boolean
        | void;
        beforeExpand?: (
            ctx: {
                keys: RowKey[] | "all";
                kind: "group" | "tree";
                source: "api" | "user";
            },
        ) => boolean
        | void;
        beforeFileImport?: (ctx: { file: File }) => boolean | void;
        beforeFill?: (
            ctx: {
                direction: "x" | "y";
                sourceRange: CellRange;
                targetRange: CellRange;
            },
        ) => boolean
        | void;
        beforeFilter?: (
            ctx: { model: FilterModel; source: "api" | "user"; tree?: FilterNode },
        ) => boolean | void;
        beforeFilterPresetApply?: (
            ctx: { preset: FilterPreset; source: "api" | "user" },
        ) => boolean | void;
        beforeGroup?: (
            ctx: {
                columns: string[];
                op: "move" | "set" | "add" | "remove";
                source: "api" | "user";
            },
        ) => boolean
        | void;
        beforeGroupRowEdit?: (
            ctx: {
                columnId: string;
                groupKey: string;
                keys: (string | number)[];
                value: unknown;
            },
        ) => boolean
        | void;
        beforeHeaderGroupToggle?: (
            ctx: {
                collapsed: boolean;
                groupId: string;
                source: ColumnChangeSource;
            },
        ) => boolean
        | void;
        beforeMoveRows?: (
            ctx: {
                keys: RowKey[];
                kind: "move" | "indent" | "outdent";
                target: MoveTarget;
            },
        ) => boolean
        | void;
        beforeOrderIndexChange?: (
            ctx: {
                changes: { from: number | null; rowKey: RowKey; to: number }[];
                field: string;
                renumbered: boolean;
                source: "api" | "move";
            },
        ) => boolean
        | void;
        beforePageChange?: (
            ctx: {
                from: number;
                pageSize: number;
                source: "api" | "user";
                to: number;
            },
        ) => boolean
        | void;
        beforePaste?: (ctx: { text: string }) => string | boolean | void;
        beforeRedo?: () => boolean | void;
        beforeRemoveRows?: (
            ctx: {
                keys: RowKey[];
                mode?: "hide" | "delete" | "mark";
                source: "keyboard" | "api";
            },
        ) => boolean
        | void;
        beforeRowDrop?: (ctx: RowDropContext & { rows: TRow[] }) => boolean | void;
        beforeRowPanelClose?: (
            ctx: {
                dirty: boolean;
                reason: "api" | "cancel" | "switch";
                rowKey: RowKey;
            },
        ) => boolean
        | void;
        beforeRowPanelOpen?: (
            ctx: { previousKey: RowKey | null; rowKey: RowKey },
        ) => boolean | void;
        beforeRowPanelSave?: (
            ctx: { changes: RowPanelChanges; rowKey: RowKey },
        ) => boolean | void;
        beforeSort?: (
            ctx: { model: SortItem[]; source: "api" | "user" },
        ) => boolean | void;
        beforeTreeChildrenLoad?: (
            ctx: { page: number; parentKey: RowKey },
        ) => boolean | void;
        beforeUndo?: () => boolean | void;
        canSelect?: (
            ctx: { columnId: string | null; kind: "cell" | "row"; rowKey: RowKey },
        ) => boolean;
        copyCell?: (
            ctx: { columnId: string; rowKey: RowKey; text: string; value: unknown },
        ) => string | void;
        copyHeader?: (ctx: { columnId: string; text: string }) => string | void;
        entryFocus?: (
            ctx: { direction: "api" | "click" | "next" | "prev" },
        ) => string | void | { columnId: string; rowKey: RowKey } | null;
        nextCell?: (
            ctx: {
                direction: "next" | "prev" | "up" | "down" | "left" | "right";
                event: KeyboardEvent;
                from: { columnId: string; rowKey: RowKey } | null;
            },
        ) => void
        | { columnId: string; rowKey: RowKey }
        | null;
        nextHeader?: (
            ctx: {
                direction: "next" | "prev";
                event: KeyboardEvent;
                from: string | null;
            },
        ) => string
        | void
        | null;
        onKeyDown?: (
            ctx: {
                columnId: string | null;
                editing: boolean;
                event: KeyboardEvent;
                rowKey: RowKey | null;
            },
        ) => boolean
        | void;
        pasteCell?: (
            ctx: { columnId: string; rowKey: RowKey; text: string },
        ) => string | void;
        popupCreated?: (
            ctx: {
                element: HTMLElement;
                kind:
                    | "filter"
                    | "column-menu"
                    | "cell-menu"
                    | "picker"
                    | "tooltip"
                    | "editor";
            },
        ) => void;
        rowRendered?: (
            ctx: { element: HTMLElement; index: number; rowKey: RowKey },
        ) => void;
        tabOut?: (
            ctx: { direction: "next" | "prev"; event: KeyboardEvent },
        ) => boolean | void;
        transformEdit?: (
            ctx: {
                columnId: string;
                oldValue: unknown;
                rowKey: RowKey;
                value: unknown;
            },
        ) => unknown;
    }

    Type Parameters

    • TRow = unknown

    Hierarchy (View Summary)

    Index
    beforeAddRows?: (
        ctx: { rows: TRow[]; source: "keyboard" | "api" },
    ) => boolean | void
    beforeCellsDrag?: (ctx: { range: CellRange }) => boolean | void
    beforeCellsDrop?: (
        ctx: {
            from: CellRange;
            mode: "move" | "copy";
            to: CellRange;
            values: unknown[][];
        },
    ) => boolean
    | void
    beforeChartCreate?: (
        ctx: {
            data: ChartData;
            source: "selection" | "visible" | "all" | "columns";
            type: ChartType;
        },
    ) => boolean
    | void
    beforeCollapse?: (
        ctx: {
            keys: RowKey[] | "all";
            kind: "group" | "tree";
            source: "api" | "user";
        },
    ) => boolean
    | void
    beforeColumnChange?: (
        ctx: {
            columnId: string;
            type:
                | "hide"
                | "move"
                | "add"
                | "remove"
                | "show"
                | "pin"
                | "unpin"
                | "resize"
                | "update";
        },
    ) => boolean
    | void
    beforeContextMenu?: (
        ctx: {
            columnId: string | null;
            event: MouseEvent | null;
            rowKey: RowKey | null;
            zone: ContextMenuZone;
        },
    ) => boolean
    | void

    우클릭·길게 누르기로 메뉴가 열리기 전. false면 기본 메뉴를 열지 않는다.

    beforeCopy?: (
        ctx: { columns: string[]; headers: boolean; rows: number },
    ) => boolean | void

    복사 직전. false면 복사하지 않는다.

    beforeCut?: (
        ctx: { columns: string[]; headers: boolean; rows: number },
    ) => boolean | void

    잘라내기 직전. false면 아무 일도 없다.

    beforeEdit?: (
        ctx: {
            columnId: string;
            rowKey: RowKey;
            trigger: CellEditTrigger;
            value: unknown;
        },
    ) => boolean
    | void
    beforeExpand?: (
        ctx: {
            keys: RowKey[] | "all";
            kind: "group" | "tree";
            source: "api" | "user";
        },
    ) => boolean
    | void
    beforeFileImport?: (ctx: { file: File }) => boolean | void
    beforeFill?: (
        ctx: {
            direction: "x" | "y";
            sourceRange: CellRange;
            targetRange: CellRange;
        },
    ) => boolean
    | void
    beforeFilter?: (
        ctx: { model: FilterModel; source: "api" | "user"; tree?: FilterNode },
    ) => boolean | void
    beforeFilterPresetApply?: (
        ctx: { preset: FilterPreset; source: "api" | "user" },
    ) => boolean | void
    beforeGroup?: (
        ctx: {
            columns: string[];
            op: "move" | "set" | "add" | "remove";
            source: "api" | "user";
        },
    ) => boolean
    | void
    beforeGroupRowEdit?: (
        ctx: {
            columnId: string;
            groupKey: string;
            keys: (string | number)[];
            value: unknown;
        },
    ) => boolean
    | void
    beforeHeaderGroupToggle?: (
        ctx: { collapsed: boolean; groupId: string; source: ColumnChangeSource },
    ) => boolean | void
    beforeMoveRows?: (
        ctx: {
            keys: RowKey[];
            kind: "move" | "indent" | "outdent";
            target: MoveTarget;
        },
    ) => boolean
    | void
    beforeOrderIndexChange?: (
        ctx: {
            changes: { from: number | null; rowKey: RowKey; to: number }[];
            field: string;
            renumbered: boolean;
            source: "api" | "move";
        },
    ) => boolean
    | void
    beforePageChange?: (
        ctx: {
            from: number;
            pageSize: number;
            source: "api" | "user";
            to: number;
        },
    ) => boolean
    | void
    beforePaste?: (ctx: { text: string }) => string | boolean | void

    붙여넣기 직전. false면 취소, 문자열이면 그 문자열로 바꿔 붙인다.

    beforeRedo?: () => boolean | void
    beforeRemoveRows?: (
        ctx: {
            keys: RowKey[];
            mode?: "hide" | "delete" | "mark";
            source: "keyboard" | "api";
        },
    ) => boolean
    | void

    mode는 이번 삭제 방식(removeMode). 생략하면 'delete'.

    beforeRowDrop?: (ctx: RowDropContext & { rows: TRow[] }) => boolean | void
    beforeRowPanelClose?: (
        ctx: {
            dirty: boolean;
            reason: "api" | "cancel" | "switch";
            rowKey: RowKey;
        },
    ) => boolean
    | void

    고친 값이 있을 때만 불린다(discard: true로 닫으면 부르지 않는다).

    beforeRowPanelOpen?: (
        ctx: { previousKey: RowKey | null; rowKey: RowKey },
    ) => boolean | void
    beforeRowPanelSave?: (
        ctx: { changes: RowPanelChanges; rowKey: RowKey },
    ) => boolean | void
    beforeSort?: (
        ctx: { model: SortItem[]; source: "api" | "user" },
    ) => boolean | void
    beforeTreeChildrenLoad?: (
        ctx: { page: number; parentKey: RowKey },
    ) => boolean | void
    beforeUndo?: () => boolean | void
    canSelect?: (
        ctx: { columnId: string | null; kind: "cell" | "row"; rowKey: RowKey },
    ) => boolean
    copyCell?: (
        ctx: { columnId: string; rowKey: RowKey; text: string; value: unknown },
    ) => string | void

    복사할 셀 텍스트를 바꾼다. 문자열을 돌려주면 그 셀 텍스트가 된다.

    copyHeader?: (ctx: { columnId: string; text: string }) => string | void

    복사할 머리글 텍스트를 바꾼다.

    entryFocus?: (
        ctx: { direction: "api" | "click" | "next" | "prev" },
    ) => string | void | { columnId: string; rowKey: RowKey } | null

    바깥에서 그리드로 포커스가 들어올 때 받을 칸(또는 머리글 컬럼 id).

    nextCell?: (
        ctx: {
            direction: "next" | "prev" | "up" | "down" | "left" | "right";
            event: KeyboardEvent;
            from: { columnId: string; rowKey: RowKey } | null;
        },
    ) => void
    | { columnId: string; rowKey: RowKey }
    | null

    키로 포커스가 옮겨 갈 칸을 바꾼다. 칸을 돌려주면 그 칸, null이면 그대로, 없으면 기본 이동.

    nextHeader?: (
        ctx: {
            direction: "next" | "prev";
            event: KeyboardEvent;
            from: string | null;
        },
    ) => string
    | void
    | null

    머리글 포커스가 옮겨 갈 컬럼 id를 바꾼다.

    onKeyDown?: (
        ctx: {
            columnId: string | null;
            editing: boolean;
            event: KeyboardEvent;
            rowKey: RowKey | null;
        },
    ) => boolean
    | void

    true면 그리드는 그 키를 처리하지 않는다.

    pasteCell?: (
        ctx: { columnId: string; rowKey: RowKey; text: string },
    ) => string | void

    붙여넣을 셀 텍스트를 파싱 전에 바꾼다.

    popupCreated?: (
        ctx: {
            element: HTMLElement;
            kind:
                | "filter"
                | "column-menu"
                | "cell-menu"
                | "picker"
                | "tooltip"
                | "editor";
        },
    ) => void

    팝업이 만들어질 때 한 번, 보이기 전에 불린다.

    rowRendered?: (
        ctx: { element: HTMLElement; index: number; rowKey: RowKey },
    ) => void
    tabOut?: (
        ctx: { direction: "next" | "prev"; event: KeyboardEvent },
    ) => boolean | void

    Tab이 그리드 밖으로 나가려 할 때. true면 포커스를 그리드 안에 둔다.

    transformEdit?: (
        ctx: {
            columnId: string;
            oldValue: unknown;
            rowKey: RowKey;
            value: unknown;
        },
    ) => unknown

    최종 값을 돌려준다. undefined면 그대로. 컬럼 parse 다음, 검증 앞에서 불린다.