rename some events.

This commit is contained in:
Chen Lily 2024-01-23 09:22:08 +08:00
parent 10e4e52b51
commit 27b2f1052f
4 changed files with 46 additions and 37 deletions

View File

@ -975,7 +975,7 @@ export default class CustomerCommunication {
}); });
grid.extraRows = customerRecords.filter(c => !nullOrEmpty(c.Notes)).length; grid.extraRows = customerRecords.filter(c => !nullOrEmpty(c.Notes)).length;
grid.source = customerRecords; grid.source = customerRecords;
grid.selectedRowChanged = index => { grid.onSelectedRowChanged = index => {
if (index >= 0 && this._var.gridWo.selectedIndexes?.length > 0) { if (index >= 0 && this._var.gridWo.selectedIndexes?.length > 0) {
this._var.gridWo.selectedIndexes = []; this._var.gridWo.selectedIndexes = [];
} }
@ -1034,7 +1034,7 @@ export default class CustomerCommunication {
}); });
gridWo.extraRows = workOrderOnly.filter(c => !nullOrEmpty(c.Notes)).length; gridWo.extraRows = workOrderOnly.filter(c => !nullOrEmpty(c.Notes)).length;
gridWo.source = workOrderOnly; gridWo.source = workOrderOnly;
gridWo.selectedRowChanged = index => { gridWo.onSelectedRowChanged = index => {
if (index >= 0 && this._var.gridContact.selectedIndexes?.length > 0) { if (index >= 0 && this._var.gridContact.selectedIndexes?.length > 0) {
this._var.gridContact.selectedIndexes = []; this._var.gridContact.selectedIndexes = [];
} }

29
lib/ui/grid/grid.d.ts vendored
View File

@ -34,6 +34,7 @@ export class Grid {
Checkbox: 3, Checkbox: 3,
Icon: 4, Icon: 4,
Text: 5, Text: 5,
Date: 6,
isCheckbox(type: Number): boolean; isCheckbox(type: Number): boolean;
}; };
@ -41,27 +42,29 @@ export class Grid {
langs?: { all: string, ok: string, reset: string }; langs?: { all: string, ok: string, reset: string };
virtualCount?: Number; virtualCount?: Number;
rowHeight?: Number; rowHeight?: Number;
lineHeight?: Number;
extraRows?: Number; extraRows?: Number;
filterRowHeight?: Number; filterRowHeight?: Number;
height?: Number; height?: Number;
readonly?: boolean; readonly?: boolean;
multiSelect?: boolean; multiSelect?: boolean;
fullrowClick?: boolean; fullrowClick?: boolean;
allowHtml?: boolean; tooltipDisabled?: boolean;
holderDisabled?: boolean;
headerVisible?: boolean; headerVisible?: boolean;
window?: Window window?: Window
sortIndex?: Number; sortIndex?: Number;
sortDirection?: keyof GridColumnDirection; sortDirection?: keyof GridColumnDirection;
constructor(container: HTMLElement); constructor(container: HTMLElement, getText?: (id: string, def?: string) => string);
willSelect?: (index: Number, colIndex: Number) => boolean; willSelect?: (index: Number, colIndex: Number) => boolean;
selectedRowChanged?: (index?: Number) => void;
cellDblClicked?: (index: Number, colIndex: Number) => void;
cellClicked?: (index: Number, colIndex: Number) => boolean; cellClicked?: (index: Number, colIndex: Number) => boolean;
rowDblClicked?: (index: Number) => void;
columnChanged?: <K extends keyof GridColumnColumnEventMap>(type: K, index: Number, value: Number | keyof GridColumnDirection) => void; 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>; get source(): Array<GridItem | any>;
set source(list: Array<GridItem | any>); set source(list: Array<GridItem | any>);
@ -72,15 +75,19 @@ export class Grid {
get scrollTop(): Number; get scrollTop(): Number;
set scrollTop(top: Number); set scrollTop(top: Number);
readonly virtual: boolean; get element(): HTMLElement
readonly sortKey: string | undefined; get virtual(): boolean;
readonly selectedIndex: Number | -1; get sortKey(): string | undefined;
get selectedIndex(): Number | -1;
init(container?: HTMLElement): void; init(container?: HTMLElement): void;
setData(source: Array<GridItem | any>): void;
setItem(index: Number, item: GridItem | any): void;
scrollToIndex(index: Number): void; scrollToIndex(index: Number): void;
resize(force?: boolean): void; resize(force?: boolean): void;
reload(): void; reload(keep?: boolean): void;
refresh(): void; refresh(): void;
resetChange(): void; resetChange(): void;
sortColumn(reload?: boolean): void; sortColumn(reload?: boolean): void;
clearHeaderCheckbox(): void;
} }

View File

@ -100,11 +100,13 @@ export class Grid {
sortDirection = 1; sortDirection = 1;
willSelect; willSelect;
selectedRowChanged;
cellDblClicked;
cellClicked; cellClicked;
rowDblClicked;
columnChanged; onSelectedRowChanged;
onCellDblClicked;
onRowDblClicked;
onColumnChanged;
onBodyScrolled;
static ColumnTypes = { static ColumnTypes = {
Common: 0, Common: 0,
@ -212,8 +214,8 @@ export class Grid {
} }
}); });
} }
if (typeof this.selectedRowChanged === 'function') { if (typeof this.onSelectedRowChanged === 'function') {
this.selectedRowChanged(); this.onSelectedRowChanged();
} }
} }
@ -273,8 +275,8 @@ export class Grid {
this._var.selectedIndexes = [index]; this._var.selectedIndexes = [index];
this.scrollToIndex(index); this.scrollToIndex(index);
this.refresh(); this.refresh();
if (typeof this.selectedRowChanged === 'function') { if (typeof this.onSelectedRowChanged === 'function') {
this.selectedRowChanged(index); this.onSelectedRowChanged(index);
} }
e.stopPropagation(); e.stopPropagation();
} }
@ -948,8 +950,8 @@ export class Grid {
} }
}); });
if (typeof this.columnChanged === 'function') { if (typeof this.onColumnChanged === 'function') {
this.columnChanged(ColumnChangedType.Reorder, index, targetIndex); this.onColumnChanged(ColumnChangedType.Reorder, index, targetIndex);
} }
} }
} }
@ -1038,8 +1040,8 @@ export class Grid {
this.sortIndex = index; this.sortIndex = index;
} }
this.sortColumn(); this.sortColumn();
if (typeof this.columnChanged === 'function') { if (typeof this.onColumnChanged === 'function') {
this.columnChanged(ColumnChangedType.Sort, index, this.sortDirection); this.onColumnChanged(ColumnChangedType.Sort, index, this.sortDirection);
} }
} }
} }
@ -1363,8 +1365,8 @@ export class Grid {
delete attr.sizing; delete attr.sizing;
delete attr.autoResize; delete attr.autoResize;
this._changeColumnWidth(index, width); this._changeColumnWidth(index, width);
if (typeof this.columnChanged === 'function') { if (typeof this.onColumnChanged === 'function') {
this.columnChanged(ColumnChangedType.Resize, index, width); this.onColumnChanged(ColumnChangedType.Resize, index, width);
} }
} }
} }
@ -1391,8 +1393,8 @@ export class Grid {
if (width > 0 && width !== col.width) { if (width > 0 && width !== col.width) {
width += 12; width += 12;
this._changeColumnWidth(index, width); this._changeColumnWidth(index, width);
if (typeof this.columnChanged === 'function') { if (typeof this.onColumnChanged === 'function') {
this.columnChanged(ColumnChangedType.Resize, index, width); this.onColumnChanged(ColumnChangedType.Resize, index, width);
} }
} }
} }
@ -1429,8 +1431,8 @@ export class Grid {
if (this._var.colAttrs.__filtering != null) { if (this._var.colAttrs.__filtering != null) {
this._onCloseFilter(); this._onCloseFilter();
} }
if (this.bodyScrolled === 'function') { if (this.onBodyScrolled === 'function') {
this.bodyScrolled(e); this.onBodyScrolled(e);
} }
if (!this.virtual) { if (!this.virtual) {
return; return;
@ -1544,8 +1546,8 @@ export class Grid {
} }
}); });
} }
if (typeof this.selectedRowChanged === 'function') { if (typeof this.onSelectedRowChanged === 'function') {
this.selectedRowChanged(selectedIndex); this.onSelectedRowChanged(selectedIndex);
} }
} }
this._var.selectedColumnIndex = colIndex; this._var.selectedColumnIndex = colIndex;
@ -1562,13 +1564,13 @@ export class Grid {
return; return;
} }
const index = this.selectedIndex; const index = this.selectedIndex;
if (typeof this.rowDblClicked === 'function') { if (typeof this.onRowDblClicked === 'function') {
this.rowDblClicked(index); this.onRowDblClicked(index);
} }
if (typeof this.cellDblClicked === 'function') { if (typeof this.onCellDblClicked === 'function') {
const colIndex = this._var.selectedColumnIndex; const colIndex = this._var.selectedColumnIndex;
if (this.fullrowClick || colIndex >= 0) { if (this.fullrowClick || colIndex >= 0) {
this.cellDblClicked(index, colIndex); this.onCellDblClicked(index, colIndex);
} }
} }
} }

Binary file not shown.