UNPKG

@codenameryuu/adonis-datatable

Version:
110 lines (109 loc) 5.01 kB
import Request from './request.js'; import { HttpContext } from '@adonisjs/core/http'; import Config from './config.js'; import { Exception } from '@adonisjs/core/exceptions'; import { DataTable } from './types/index.js'; export declare abstract class DataTableAbstract implements DataTable { protected ctx: HttpContext; protected config: Config; protected request: Request; protected $columns: Record<string, any>; protected $columnDef: Record<string, any>; protected $extraColumns: string[]; protected totalRecords: number; protected filteredRecords: number; protected $skipTotalRecords: boolean; protected autoFilter: boolean; protected filterCallback: Function | null; protected $templates: Record<string, any>; protected orderCallback: Function | null; protected $skipPaging: boolean; protected appends: Record<string, any>; protected $editOnlySelectedColumns: boolean; protected $dataObject: boolean; protected $queryLogging: Record<string, any>[]; constructor(); static canCreate(_source: any): boolean; static create<T>(this: new (source: any) => T, source: any): T; /** * Implement function */ protected abstract defaultOrdering(): any; /** * Implement function */ protected abstract resolveCallback(): any; /** * Implement function */ abstract dataResults(): Promise<any[]>; /** * Implement function */ abstract count(): Promise<number>; /** * Implement function */ abstract columnSearch(): void; /** * Implement function */ abstract paging(): void; /** * Implement function */ abstract results(): Promise<Record<string, any> | void>; /** * Implement function */ abstract globalSearch(keyword: string): void; protected prepareContext(): void; totalCount(): Promise<number>; protected isBlacklisted(column: string): boolean; protected filterRecords(): Promise<void>; protected smartGlobalSearch(keyword: string): void; protected filteredCount(): Promise<number>; protected paginate(): void; protected processResults(results: Record<string, any>[]): Record<string, any>[]; protected render(data: any[]): Record<string, any>; protected attachAppends(data: Record<string, any>): Record<string, any>; protected showDebugger(output: Record<string, any>): Record<string, any>; protected errorResponse(exception: Exception): Record<string, any> | void; protected setupKeyword(value: string): string; protected getColumnName(index: number, wantsAlias?: boolean): string | null; protected getColumnNameByIndex(index: number): string; protected getPrimaryKeyName(): string; setContext(ctx: HttpContext): this; addColumn(name: string, content: (<T extends abstract new (...args: any) => any>(row: InstanceType<T>) => string | number) | string | number, order?: boolean): this; addIndexColumn(): this; editColumn(name: string, content: any): this; removeColumn(...names: string[]): this; getColumnsDefinition(): Record<string, any>; only(columns?: string[]): this; escapeColumns(columns?: string): this; rawColumns(columns: string[], merge?: boolean): this; setRowClass(content: (<T extends abstract new (...args: any) => any>(query: InstanceType<T>) => string | number) | string): this; setRowId(content: (<T extends abstract new (...args: any) => any>(query: InstanceType<T>) => string | number) | string): this; setRowData(data: Record<string, (<T extends abstract new (...args: any) => any>(query: InstanceType<T>) => string) | string>): this; addRowData(key: string, value: (<T extends abstract new (...args: any) => any>(query: InstanceType<T>) => string) | string): this; setRowAttr(data: Record<string, (<T extends abstract new (...args: any) => any>(query: InstanceType<T>) => string | number) | string | number>): this; addRowAttr(key: string, value: (<T extends abstract new (...args: any) => any>(query: InstanceType<T>) => string | number) | string): this; with(key: any, value?: any): this; withQuery(key: string, callback: <T extends abstract new (...args: any) => any>(query: InstanceType<T>) => string): this; order(callback: <T extends abstract new (...args: any) => any>(query: InstanceType<T>) => void): this; blacklist(blacklist: any[]): this; whitelist(whitelist?: string | string[]): this; smart(state?: boolean): this; startsWithSearch(state?: boolean): this; setTotalRecords(total: number): this; skipTotalRecords(): this; setFilteredRecords(total: number): this; skipPaging(): this; pushToBlacklist(column: string): this; filtering(): void; editOnlySelectedColumns(): this; ordering(): void; filter(callback: <T extends abstract new (...args: any) => any>(query: InstanceType<T>) => void, globalSearch?: boolean): this; asJson(): this; asArray(): this; }