ui-lib/lib/ui/grid/column.d.ts
2024-01-23 10:40:49 +08:00

69 lines
2.6 KiB
TypeScript

import { Grid, GridItem, GridItemWrapper, GridSourceItem } from "./grid";
import { DropdownOptions } from "../dropdown";
interface GridColumnType {
0: "Common";
1: "Input";
2: "Dropdown";
3: "Checkbox";
4: "Icon";
5: "Text";
}
export interface GridColumnDefinition {
key?: string;
type?: keyof GridColumnType | typeof GridColumn;
caption?: string;
captionStyle?: { [key: string]: string };
width?: Number;
align?: "left" | "center" | "right";
enabled?: boolean | string | ((item: GridItem | any) => boolean);
css?: { [key: string]: string };
styleFilter?: (item: GridItem | any) => { [key: string]: string };
visible?: boolean;
resizable?: boolean;
sortable?: boolean;
orderable?: boolean;
allcheck?: boolean;
events?: { [event: string]: any };
attrs?: { [key: string]: string } | ((item: GridItem | any) => { [key: string]: string });
allowFilter?: boolean;
filter?: (item: GridItem | any) => any;
sortFilter?: (a: GridItem | any, b: GridItem | any) => -1 | 0 | 1;
bgFilter?: (item: GridItem | any) => string;
dropOptions?: DropdownOptions;
source?: Array<GridSourceItem | any> | ((item: GridItem | any) => Array<GridSourceItem | any> | Promise<Array<GridSourceItem | any>>);
iconType?: string;
iconClassName?: string | ((item: GridItem | any) => string);
text?: string;
tooltip?: string | ((item: GridItem | any) => string);
onallchecked?: (this: Grid, col: GridColumnDefinition, flag: boolean) => void;
onchanged?: (this: Grid, item: GridItem | any, value: boolean | any) => void;
}
export class GridColumn {
static create(col: GridColumnDefinition): HTMLElement;
static createEdit(trigger: (e: any) => void, col: GridColumnDefinition, container: HTMLElement, vals: GridItemWrapper): HTMLElement;
static setValue(element: HTMLElement, val: any, vals: GridItemWrapper, col: GridColumnDefinition, grid: Grid): void;
static getValue(e: any, col: GridColumnDefinition): any;
static setStyle(element: HTMLElement, style: { [key: string]: string }): void;
static setEnabled(element: HTMLElement, enabled?: boolean): void;
}
export class GridInputColumn extends GridColumn {
static get editing(): boolean;
}
export class GridTextColumn extends GridInputColumn { }
export class GridDropdownColumn extends GridColumn {
static leaveEdit(element: HTMLElement, container: HTMLElement): void;
}
export class GridCheckboxColumn extends GridColumn { }
export class GridIconColumn extends GridColumn { }
export class GridDateColumn extends GridColumn {
static formatDate(date: Date): string;
}