diff --git a/lib/app/communications/customer.js b/lib/app/communications/customer.js index f8c0158..b994c42 100644 --- a/lib/app/communications/customer.js +++ b/lib/app/communications/customer.js @@ -975,7 +975,7 @@ export default class CustomerCommunication { }); grid.extraRows = customerRecords.filter(c => !nullOrEmpty(c.Notes)).length; grid.source = customerRecords; - grid.selectedRowChanged = index => { + grid.onSelectedRowChanged = index => { if (index >= 0 && this._var.gridWo.selectedIndexes?.length > 0) { this._var.gridWo.selectedIndexes = []; } @@ -1034,7 +1034,7 @@ export default class CustomerCommunication { }); gridWo.extraRows = workOrderOnly.filter(c => !nullOrEmpty(c.Notes)).length; gridWo.source = workOrderOnly; - gridWo.selectedRowChanged = index => { + gridWo.onSelectedRowChanged = index => { if (index >= 0 && this._var.gridContact.selectedIndexes?.length > 0) { this._var.gridContact.selectedIndexes = []; } diff --git a/lib/ui/grid/grid.d.ts b/lib/ui/grid/grid.d.ts index 4bdc8bf..2107942 100644 --- a/lib/ui/grid/grid.d.ts +++ b/lib/ui/grid/grid.d.ts @@ -34,6 +34,7 @@ export class Grid { Checkbox: 3, Icon: 4, Text: 5, + Date: 6, isCheckbox(type: Number): boolean; }; @@ -41,27 +42,29 @@ export class Grid { 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; - allowHtml?: boolean; - holderDisabled?: boolean; + tooltipDisabled?: boolean; headerVisible?: boolean; window?: Window sortIndex?: Number; sortDirection?: keyof GridColumnDirection; - constructor(container: HTMLElement); + constructor(container: HTMLElement, getText?: (id: string, def?: string) => string); willSelect?: (index: Number, colIndex: Number) => boolean; - selectedRowChanged?: (index?: Number) => void; - cellDblClicked?: (index: Number, colIndex: Number) => void; cellClicked?: (index: Number, colIndex: Number) => boolean; - rowDblClicked?: (index: Number) => void; - columnChanged?: (type: K, index: Number, value: Number | keyof GridColumnDirection) => void; + + onSelectedRowChanged?: (index?: Number) => void; + onCellDblClicked?: (index: Number, colIndex: Number) => void; + onRowDblClicked?: (index: Number) => void; + onColumnChanged?: (type: K, index: Number, value: Number | keyof GridColumnDirection) => void; + onBodyScrolled?: (e: Event) => void; get source(): Array; set source(list: Array); @@ -72,15 +75,19 @@ export class Grid { get scrollTop(): Number; set scrollTop(top: Number); - readonly virtual: boolean; - readonly sortKey: string | undefined; - readonly selectedIndex: Number | -1; + get element(): HTMLElement + get virtual(): boolean; + get sortKey(): string | undefined; + get selectedIndex(): Number | -1; init(container?: HTMLElement): void; + setData(source: Array): void; + setItem(index: Number, item: GridItem | any): void; scrollToIndex(index: Number): void; resize(force?: boolean): void; - reload(): void; + reload(keep?: boolean): void; refresh(): void; resetChange(): void; sortColumn(reload?: boolean): void; + clearHeaderCheckbox(): void; } \ No newline at end of file diff --git a/lib/ui/grid/grid.js b/lib/ui/grid/grid.js index 2c4a9de..cec2afe 100644 --- a/lib/ui/grid/grid.js +++ b/lib/ui/grid/grid.js @@ -100,11 +100,13 @@ export class Grid { sortDirection = 1; willSelect; - selectedRowChanged; - cellDblClicked; cellClicked; - rowDblClicked; - columnChanged; + + onSelectedRowChanged; + onCellDblClicked; + onRowDblClicked; + onColumnChanged; + onBodyScrolled; static ColumnTypes = { Common: 0, @@ -212,8 +214,8 @@ export class Grid { } }); } - if (typeof this.selectedRowChanged === 'function') { - this.selectedRowChanged(); + if (typeof this.onSelectedRowChanged === 'function') { + this.onSelectedRowChanged(); } } @@ -273,8 +275,8 @@ export class Grid { this._var.selectedIndexes = [index]; this.scrollToIndex(index); this.refresh(); - if (typeof this.selectedRowChanged === 'function') { - this.selectedRowChanged(index); + if (typeof this.onSelectedRowChanged === 'function') { + this.onSelectedRowChanged(index); } e.stopPropagation(); } @@ -948,8 +950,8 @@ export class Grid { } }); - if (typeof this.columnChanged === 'function') { - this.columnChanged(ColumnChangedType.Reorder, index, targetIndex); + if (typeof this.onColumnChanged === 'function') { + this.onColumnChanged(ColumnChangedType.Reorder, index, targetIndex); } } } @@ -1038,8 +1040,8 @@ export class Grid { this.sortIndex = index; } this.sortColumn(); - if (typeof this.columnChanged === 'function') { - this.columnChanged(ColumnChangedType.Sort, index, this.sortDirection); + if (typeof this.onColumnChanged === 'function') { + this.onColumnChanged(ColumnChangedType.Sort, index, this.sortDirection); } } } @@ -1363,8 +1365,8 @@ export class Grid { delete attr.sizing; delete attr.autoResize; this._changeColumnWidth(index, width); - if (typeof this.columnChanged === 'function') { - this.columnChanged(ColumnChangedType.Resize, index, width); + if (typeof this.onColumnChanged === 'function') { + this.onColumnChanged(ColumnChangedType.Resize, index, width); } } } @@ -1391,8 +1393,8 @@ export class Grid { if (width > 0 && width !== col.width) { width += 12; this._changeColumnWidth(index, width); - if (typeof this.columnChanged === 'function') { - this.columnChanged(ColumnChangedType.Resize, index, width); + if (typeof this.onColumnChanged === 'function') { + this.onColumnChanged(ColumnChangedType.Resize, index, width); } } } @@ -1429,8 +1431,8 @@ export class Grid { if (this._var.colAttrs.__filtering != null) { this._onCloseFilter(); } - if (this.bodyScrolled === 'function') { - this.bodyScrolled(e); + if (this.onBodyScrolled === 'function') { + this.onBodyScrolled(e); } if (!this.virtual) { return; @@ -1544,8 +1546,8 @@ export class Grid { } }); } - if (typeof this.selectedRowChanged === 'function') { - this.selectedRowChanged(selectedIndex); + if (typeof this.onSelectedRowChanged === 'function') { + this.onSelectedRowChanged(selectedIndex); } } this._var.selectedColumnIndex = colIndex; @@ -1562,13 +1564,13 @@ export class Grid { return; } const index = this.selectedIndex; - if (typeof this.rowDblClicked === 'function') { - this.rowDblClicked(index); + if (typeof this.onRowDblClicked === 'function') { + this.onRowDblClicked(index); } - if (typeof this.cellDblClicked === 'function') { + if (typeof this.onCellDblClicked === 'function') { const colIndex = this._var.selectedColumnIndex; if (this.fullrowClick || colIndex >= 0) { - this.cellDblClicked(index, colIndex); + this.onCellDblClicked(index, colIndex); } } } diff --git a/readme/Grid 控件接口文档.docx b/readme/Grid 控件接口文档.docx index 393953e..2a6a13a 100644 Binary files a/readme/Grid 控件接口文档.docx and b/readme/Grid 控件接口文档.docx differ