ui-lib/lib/ui/grid/grid.d.ts
2024-01-23 09:22:08 +08:00

93 lines
2.5 KiB
TypeScript

import { GridColumnDefinition } from "./column"
export interface GridItem {
Value: any;
DisplayValue: string;
}
export interface GridItemWrapper {
values: Array<GridItem | any>;
source: { [key: string]: Array<GridSourceItem> };
}
export interface GridSourceItem {
value: string;
text: string;
}
interface GridColumnDirection {
[-1]: Number,
1: Number
}
interface GridColumnColumnEventMap {
"reorder": string,
"resize": string,
"sort": string
}
export class Grid {
static ColumnTypes: {
Common: 0,
Input: 1,
Dropdown: 2,
Checkbox: 3,
Icon: 4,
Text: 5,
Date: 6,
isCheckbox(type: Number): boolean;
};
columns: Array<GridColumnDefinition>;
langs?: { all: string, ok: string, reset: string };
virtualCount?: Number;
rowHeight?: Number;
lineHeight?: Number;
extraRows?: Number;
filterRowHeight?: Number;
height?: Number;
readonly?: boolean;
multiSelect?: boolean;
fullrowClick?: boolean;
tooltipDisabled?: boolean;
headerVisible?: boolean;
window?: Window
sortIndex?: Number;
sortDirection?: keyof GridColumnDirection;
constructor(container: HTMLElement, getText?: (id: string, def?: string) => string);
willSelect?: (index: Number, colIndex: Number) => boolean;
cellClicked?: (index: Number, colIndex: Number) => boolean;
onSelectedRowChanged?: (index?: Number) => void;
onCellDblClicked?: (index: Number, colIndex: Number) => void;
onRowDblClicked?: (index: Number) => void;
onColumnChanged?: <K extends keyof GridColumnColumnEventMap>(type: K, index: Number, value: Number | keyof GridColumnDirection) => void;
onBodyScrolled?: (e: Event) => void;
get source(): Array<GridItem | any>;
set source(list: Array<GridItem | any>);
get selectedIndexes(): Array<Number>;
set selectedIndexes(indexes: Array<Number>);
get loading(): boolean;
set loading(flag: boolean);
get scrollTop(): Number;
set scrollTop(top: Number);
get element(): HTMLElement
get virtual(): boolean;
get sortKey(): string | undefined;
get selectedIndex(): Number | -1;
init(container?: HTMLElement): void;
setData(source: Array<GridItem | any>): void;
setItem(index: Number, item: GridItem | any): void;
scrollToIndex(index: Number): void;
resize(force?: boolean): void;
reload(keep?: boolean): void;
refresh(): void;
resetChange(): void;
sortColumn(reload?: boolean): void;
clearHeaderCheckbox(): void;
}