@eclipse-scout/core
Version:
Eclipse Scout runtime
359 lines • 16 kB
TypeScript
/// <reference types="jquery" />
import { AggregateTableRow, Alignment, Cell, CellEditorPopup, ColumnComparator, ColumnEventMap, ColumnModel, ColumnOptimalWidthMeasurer, ColumnUserFilter, Event, EventHandler, InitModelOf, ObjectWithType, ObjectWithUuid, PropertyEventEmitter, Session, SomeRequired, Status, Table, TableColumnMovedEvent, TableHeader, TableHeaderMenu, TableRow, UuidPathOptions, ValueField } from '../../index';
export declare class Column<TValue = string> extends PropertyEventEmitter implements ColumnModel<TValue>, ObjectWithType, ObjectWithUuid {
model: ColumnModel<TValue>;
initModel: SomeRequired<this['model'], 'parent'>;
eventMap: ColumnEventMap;
self: Column<any>;
objectType: string;
id: string;
uuid: string;
autoOptimizeWidth: boolean;
/** true if content of the column changed and width has to be optimized */
autoOptimizeWidthRequired: boolean;
session: Session;
autoOptimizeMaxWidth: number;
cssClass: string;
editable: boolean;
removable: boolean;
modifiable: boolean;
fixedWidth: boolean;
fixedPosition: boolean;
grouped: boolean;
headerCssClass: string;
headerIconId: string;
headerHtmlEnabled: boolean;
headerTooltipText: string;
headerBackgroundColor: string;
headerForegroundColor: string;
headerFont: string;
headerTooltipHtmlEnabled: boolean;
horizontalAlignment: Alignment;
htmlEnabled: boolean;
initialAlwaysIncludeSortAtBegin: boolean;
initialAlwaysIncludeSortAtEnd: boolean;
index: number;
primaryKey: boolean;
guiOnly: boolean;
mandatory: boolean;
optimalWidthMeasurer: ColumnOptimalWidthMeasurer;
sortActive: boolean;
checkable: boolean;
sortAscending: boolean;
sortIndex: number;
summary: boolean;
type: string;
width: number;
initialWidth: number;
minWidth: number;
showSeparator: boolean;
parent: Table;
tableNodeColumn: boolean;
maxLength: number;
text: string;
textWrap: boolean;
filterType: string;
comparator: ColumnComparator;
visible: boolean;
textBased: boolean;
headerMenuEnabled: boolean;
tableNodeLevel0CellPadding: number;
expandableIconLevel0CellPadding: number;
nodeColumnCandidate: boolean;
modelClass: string;
classId: string;
/** Set by TableHeader */
$header: JQuery;
$separator: JQuery;
/**
* Contains the width the cells of the column really have (only set in Chrome due to a Chrome bug, see Table._updateRealColumnWidths)
* @internal
*/
_realWidth: number;
protected _tableColumnsChangedHandler: EventHandler<TableColumnMovedEvent | Event<Table>>;
constructor();
static DEFAULT_MIN_WIDTH: number;
static SMALL_MIN_WIDTH: number;
static NARROW_MIN_WIDTH: number;
protected _init(model: InitModelOf<this>): void;
destroy(): void;
/**
* Override this function in order to implement custom destroy logic.
*/
protected _destroy(): void;
buildUuid(useFallback?: boolean): string;
buildUuidPath(options?: UuidPathOptions): string;
setUuid(uuid: string): void;
/** @internal */
_setParent(parent: Table): void;
get table(): Table;
protected _resolveTextKeys(properties: string[]): void;
protected _resolveIconIds(properties: string[]): void;
/**
* Converts the vararg if it is of type string to an object with
* a property 'text' with the original value.
*
* Example:
* 'My Company' --> { text: 'MyCompany'; }
*
* @see JsonCell.java
* @param vararg either a Cell instance or a scalar value
*/
initCell(vararg: TValue | Cell<TValue>, row?: TableRow): Cell<TValue>;
/**
* Ensures that a Cell instance is returned.
* When vararg is a scalar value a new Cell instance is created and the value is set as {@link cell.value} property.
*
* @param vararg either a Cell instance or a scalar value
*/
private _ensureCell;
/**
* Override this method to create a value based on the given scalar value.
*/
protected _ensureValue(scalar: TValue | string): TValue;
protected _updateCellText(row: TableRow, cell: Cell<TValue>): void;
protected _formatValue(value: TValue, row?: TableRow): string | JQuery.Promise<string>;
/**
* If cell does not define properties, use column values.
* Override this function to implement type specific init cell behavior.
*
*/
protected _initCell(cell: Cell<TValue>): Cell<TValue>;
buildCellForRow(row: TableRow): string;
buildCellForAggregateRow(aggregateRow: AggregateTableRow): string;
buildCell(cell: Cell<TValue>, row: TableRow | {
hasError?: boolean;
expanded?: boolean;
expandable?: boolean;
parentRow?: TableRow;
}): string;
protected _buildCell(cell: Cell<TValue>, content: string, style: string, cssClass: string): string;
protected _expandIcon(expanded: boolean, rowPadding: number): string;
protected _icon(iconId: string, hasText: boolean): string;
protected _text(cell: Cell<TValue>): string;
protected _cellCssClass(cell: Cell<TValue>, tableNode?: boolean): string;
protected _cellStyle(cell: Cell<TValue>, tableNodeColumn?: boolean, rowPadding?: number): string;
onMouseUp(event: JQuery.MouseUpEvent, $row: JQuery): void;
isCellEditable(row: TableRow, cell: Cell<TValue>, event: JQuery.MouseEventBase): boolean;
startCellEdit(row: TableRow, field: ValueField<TValue>): CellEditorPopup<TValue>;
protected _createEditorPopup(row: TableRow, cell: Cell<TValue>): CellEditorPopup<TValue>;
/**
* @returns the cell object for this column and the given row.
*/
cell(row: TableRow): Cell<TValue>;
/**
* @returns all cells for this column.
*/
cells(): Cell<TValue>[];
/**
* Creates an artificial cell from the properties relevant for the column header.
*/
headerCell(): Cell<string>;
/**
* @returns the cell object for this column from the first selected row in the table.
*/
selectedCell(): Cell<TValue>;
/**
* @returns all selected cells for this column in the same order as the {@link Table.rows}.
*/
selectedCells(): Cell<TValue>[];
/**
* @returns the cell value for this column from the first selected row in the table.
*/
selectedCellValue(): TValue;
/**
* @returns all selected cell values for this column in the same order as the {@link Table.rows}.
*/
selectedCellValues(): TValue[];
/**
* @returns the value for the first row that is checked.
*/
checkedCellValue(): TValue;
/**
* @returns all cell values for this column for each checked row in the same order as the {@link Table.rows}.
*/
checkedCellValues(): TValue[];
/**
* @returns the value of the cell. If it is text based as string otherwise the raw value.
*/
cellValueOrText(row: TableRow): TValue | string;
/**
* @returns the cell value of the given row.
*/
cellValue(row: TableRow): TValue;
/**
* @returns all cell values of this column.
*/
cellValues(): TValue[];
/**
* @returns the cell text of the given row.
*/
cellText(row: TableRow): string;
/**
* @returns the cell value to be used for grouping and filtering (chart, column filter).
*/
cellValueOrTextForCalculation(row: TableRow): TValue | string;
protected _preprocessValueOrTextForCalculation(value: TValue | string, cell?: Cell<TValue>): TValue | string;
protected _preprocessTextForCalculation(text: string, htmlEnabled?: boolean): string;
/**
* @returns the cell text to be used for table grouping
*/
cellTextForGrouping(row: TableRow): string;
protected _preprocessTextForGrouping(text: string, htmlEnabled?: boolean): string;
/**
* @returns the cell text to be used for the text filter
*/
cellTextForTextFilter(row: TableRow): string;
protected _preprocessTextForTextFilter(text: string, htmlEnabled?: boolean): string;
/**
* @returns the cell text to be used for the table row detail.
*/
cellTextForRowDetail(row: TableRow): string;
/**
* Removes html tags, converts to single line, removes leading and trailing whitespaces.
*/
protected _preprocessText(text: string, options: {
removeHtmlTags?: boolean;
removeNewlines?: boolean;
trim?: boolean;
}): string;
/**
* Updates the cell value for the given row.
*
* The value will be formatted using {@link _formatValue} and the result set as cell text using {@link setCellText}.
*/
setCellValue(row: TableRow, value: TValue): void;
protected _setCellValue(row: TableRow, value: TValue, cell: Cell<TValue>): void;
setCellTextDeferred(promise: JQuery.Promise<string>, row: TableRow, cell: Cell<TValue>): void;
/**
* Updates the cell text for the given row and calls {@link Table.updateRow} if the row is initialized and the table contains it.
*/
setCellText(row: TableRow, text: string, cell?: Cell<TValue>): void;
setCellErrorStatus(row: TableRow, errorStatus: Status, cell?: Cell<TValue>): void;
setCellIconId(row: TableRow, iconId: string): void;
setHorizontalAlignment(horizontalAlignment: Alignment): void;
setEditable(editable: boolean): void;
setMandatory(mandatory: boolean): void;
setCssClass(cssClass: string): void;
setSummary(summary: boolean): void;
setWidth(width: number): void;
setFixedPosition(fixedPosition: boolean): void;
setFixedWidth(fixedWidth: boolean): void;
setModifiable(modifiable: boolean): void;
setRemovable(removable: boolean): void;
createAggrGroupCell(row: TableRow): Cell<TValue>;
createAggrValueCell(value: TValue): Cell<TValue>;
createAggrEmptyCell(): Cell<TValue>;
calculateOptimalWidth(): number | JQuery.Promise<number>;
/**
* Returns a type specific column user-filter. The default impl. returns a ColumnUserFilter.
* Subclasses that must return another type, must simply change the value of the 'filterType' property.
*/
createFilter(): ColumnUserFilter;
/**
* @returns true if the column has an active filter, false if not.
*/
get filtered(): boolean;
/**
* Returns a table header menu. Subclasses can override this method to create a column specific table header menu.
*/
createTableHeaderMenu(tableHeader: TableHeader): TableHeaderMenu;
/**
* @returns a field instance used as editor when a cell of this column is in edit mode.
*/
createEditor(row: TableRow): ValueField<TValue>;
/**
* Depending on the type of column the editor may need to be initialized differently.
* The default implementation either copies the value to the field if the field has no error or copies the text and error status if it has an error.
*/
protected _initEditorField(field: ValueField<TValue>, cell: Cell<TValue>): void;
protected _updateEditorFromValidCell(field: ValueField<TValue>, cell: Cell<TValue>): void;
protected _updateEditorFromInvalidCell(field: ValueField<TValue>, cell: Cell<TValue>): void;
protected _createEditor(row: TableRow): ValueField<TValue, any>;
updateCellFromEditor(row: TableRow, field: ValueField<TValue>): void;
protected _updateCellFromInvalidEditor(row: TableRow, field: ValueField<TValue>): void;
protected _updateCellFromValidEditor(row: TableRow, field: ValueField<TValue>): void;
/**
* Override this function to install a specific compare function on a column instance.
* The default impl. installs a generic comparator working with less than and greater than.
*
* @returns whether or not it was possible to install a compare function. If not, client side sorting is disabled.
*/
installComparator(): boolean;
/**
* @returns whether or not it is possible to sort this column. As a side effect a comparator is installed.
*/
isSortingPossible(): boolean;
compare(row1: TableRow, row2: TableRow): number;
/**
* @deprecated use {@link visible} directly. Will be removed in an upcoming release.
*/
isVisible(): boolean;
/**
* Computes the visibility of the column ignoring the compacted state.
*
* @returns true if all visible dimensions excluding the dimension `compacted` of the column are true.
* So even if the column is compacted, it will return true if all other dimensions are true.
*/
get visibleIgnoreCompacted(): boolean;
/**
* Sets the 'default' dimension for the {@link Column.visible} property and recomputes its state.
*
* @param visible the new visible value for the 'default' dimension, or an object containing the new visible dimensions.
* @param redraw true, to redraw the table immediately, false if not. Default is {@link initialized}.
* When false is used, the redraw needs to be triggered manually using {@link Table.onColumnVisibilityChanged}.
* @see ColumnModel.visible
*/
setVisible(visible: boolean | Record<string, boolean>, redraw?: boolean): void;
/**
* Sets the 'granted' dimension for the {@link Column.visible} property and recomputes its state.
*
* @param visibleGranted the new visible value for the 'granted' dimension.
* @param redraw true, to redraw the table immediately, false if not. Default is {@link initialized}.
* When false is used, the redraw needs to be triggered manually using {@link Table.onColumnVisibilityChanged}.
* @see ColumnModel.visibleGranted
*/
setVisibleGranted(visibleGranted: boolean, redraw?: boolean): void;
get visibleGranted(): boolean;
/**
* Sets the 'displayable' dimension for the {@link Column.visible} property and recomputes its state.
*
* @param displayable the new visible value for the 'displayable' dimension.
* @param redraw true, to redraw the table immediately, false if not. Default is {@link initialized}.
* When false is used, the redraw needs to be triggered manually using {@link Table.onColumnVisibilityChanged}.
* @see ColumnModel.displayable
*/
setDisplayable(displayable: boolean, redraw?: boolean): void;
get displayable(): boolean;
/**
* Sets the 'compacted' dimension for the {@link Column.visible} property and recomputes its state.
*
* @param displayable the new visible value for the 'compacted' dimension.
* @param redraw true, to redraw the table immediately, false if not. Default is {@link initialized}.
* When false is used, the redraw needs to be triggered manually using {@link Table.onColumnVisibilityChanged}.
* @see ColumnModel.visible
*/
setCompacted(compacted: boolean, redraw?: boolean): void;
get compacted(): boolean;
setAutoOptimizeWidth(autoOptimizeWidth: boolean): void;
protected _setAutoOptimizeWidth(autoOptimizeWidth: boolean): void;
setMaxLength(maxLength: number): void;
setText(text: string): void;
setHeaderIconId(headerIconId: string): void;
setHeaderCssClass(headerCssClass: string): void;
setHeaderHtmlEnabled(headerHtmlEnabled: boolean): void;
setHeaderMenuEnabled(headerMenuEnabled: boolean): void;
setHeaderTooltipText(headerTooltipText: string): void;
setHeaderTooltipHtmlEnabled(headerTooltipHtmlEnabled: boolean): void;
setTextWrap(textWrap: boolean): void;
isContentValid(row: TableRow): ColumnValidationResult;
protected _hasCellValue(cell: Cell<TValue>): boolean;
protected _onTableColumnsChanged(event: TableColumnMovedEvent | Event<Table>): void;
realWidthIfAvailable(): number;
}
export type ColumnValidationResult = {
valid: boolean;
validByMandatory: boolean;
errorStatus: Status;
};
//# sourceMappingURL=Column.d.ts.map