.
This commit is contained in:
parent
09e62c4304
commit
07f87bfb9d
@ -13,7 +13,8 @@ class NoteCol extends GridColumn {
|
|||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
static setValue(element, _val, item, _col, grid) {
|
static setValue(element, _val, it, _col, grid) {
|
||||||
|
const item = it.values;
|
||||||
const name = element.querySelector('.contact-name');
|
const name = element.querySelector('.contact-name');
|
||||||
name.innerText = item.Name;
|
name.innerText = item.Name;
|
||||||
if (name.scrollWidth > name.offsetWidth) {
|
if (name.scrollWidth > name.offsetWidth) {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -113,6 +113,10 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
>.ui-check-wrapper {
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
>.arrow {
|
>.arrow {
|
||||||
|
4
lib/ui/grid/column.d.ts
vendored
4
lib/ui/grid/column.d.ts
vendored
@ -37,8 +37,8 @@ export interface GridColumnDefinition {
|
|||||||
iconClassName?: string | ((item: GridItem | any) => string);
|
iconClassName?: string | ((item: GridItem | any) => string);
|
||||||
text?: string;
|
text?: string;
|
||||||
tooltip?: string | ((item: GridItem | any) => string);
|
tooltip?: string | ((item: GridItem | any) => string);
|
||||||
onallchecked?: (this: Grid, col: GridColumnDefinition, flag: boolean) => void;
|
onAllChecked?: (this: Grid, col: GridColumnDefinition, flag: boolean) => void;
|
||||||
onchanged?: (this: Grid, item: GridItem | any, value: boolean | any) => void;
|
onChanged?: (this: Grid, item: GridItem | any, value: boolean | any, oldValue: any, e?: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GridColumn {
|
export class GridColumn {
|
||||||
|
@ -296,7 +296,8 @@ export class GridDateColumn extends GridColumn {
|
|||||||
if (col.dateMax != null) {
|
if (col.dateMax != null) {
|
||||||
date.max = col.dateMax;
|
date.max = col.dateMax;
|
||||||
}
|
}
|
||||||
date.addEventListener('change', trigger);
|
// date.addEventListener('change', trigger);
|
||||||
|
date.addEventListener('blur', trigger);
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,6 +325,9 @@ export class GridDateColumn extends GridColumn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static formatDate(date) {
|
static formatDate(date) {
|
||||||
|
if (date instanceof Date && !isNaN(date)) {
|
||||||
return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
|
return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
|
||||||
}
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
@ -248,9 +248,16 @@ export class Grid {
|
|||||||
this._var.el = null;
|
this._var.el = null;
|
||||||
this._var.refs = {};
|
this._var.refs = {};
|
||||||
this._var.rendering = true;
|
this._var.rendering = true;
|
||||||
if (!(container instanceof HTMLElement)) {
|
if (container == null) {
|
||||||
throw new Error('no specified parent.');
|
throw new Error('no specified parent.');
|
||||||
}
|
}
|
||||||
|
if (!(container instanceof HTMLElement)) {
|
||||||
|
const ele = container[0];
|
||||||
|
if (!(ele instanceof HTMLElement)) {
|
||||||
|
throw new Error(`parent type not supported. ${JSON.stringify(Object.getPrototypeOf(container))}`);
|
||||||
|
}
|
||||||
|
container = ele;
|
||||||
|
}
|
||||||
this._var.parent = container;
|
this._var.parent = container;
|
||||||
const grid = createElement('div', 'ui-grid');
|
const grid = createElement('div', 'ui-grid');
|
||||||
grid.setAttribute('tabindex', 0);
|
grid.setAttribute('tabindex', 0);
|
||||||
@ -353,7 +360,7 @@ export class Grid {
|
|||||||
const count = truncate((height - 1) / (this.rowHeight + 1)) + (RedumCount * 2) + 1;
|
const count = truncate((height - 1) / (this.rowHeight + 1)) + (RedumCount * 2) + 1;
|
||||||
if (force || count !== this._var.rowCount) {
|
if (force || count !== this._var.rowCount) {
|
||||||
this._var.rowCount = count;
|
this._var.rowCount = count;
|
||||||
this.reload();
|
this.reload(true);
|
||||||
}
|
}
|
||||||
this._var.bodyClientWidth = body.clientWidth;
|
this._var.bodyClientWidth = body.clientWidth;
|
||||||
}
|
}
|
||||||
@ -377,7 +384,7 @@ export class Grid {
|
|||||||
this._refreshSource();
|
this._refreshSource();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let length = this._var.currentSource.length;
|
let length = this._var.currentSource?.length ?? 0;
|
||||||
if (this.extraRows > 0) {
|
if (this.extraRows > 0) {
|
||||||
length += this.extraRows;
|
length += this.extraRows;
|
||||||
}
|
}
|
||||||
@ -595,7 +602,8 @@ export class Grid {
|
|||||||
}
|
}
|
||||||
const dragger = createElement('div', 'dragger');
|
const dragger = createElement('div', 'dragger');
|
||||||
const draggerCursor = createElement('layer', 'dragger-cursor');
|
const draggerCursor = createElement('layer', 'dragger-cursor');
|
||||||
header.appendChild(createElement('th', null, dragger, draggerCursor));
|
header.appendChild(
|
||||||
|
createElement('th', null, dragger, draggerCursor, createElement('div')));
|
||||||
|
|
||||||
sizer.replaceChildren();
|
sizer.replaceChildren();
|
||||||
this._var.refs.header = header;
|
this._var.refs.header = header;
|
||||||
@ -638,7 +646,7 @@ export class Grid {
|
|||||||
_adjustRows() {
|
_adjustRows() {
|
||||||
let count = this._var.rowCount;
|
let count = this._var.rowCount;
|
||||||
if (isNaN(count) || count < 0 || !this.virtual) {
|
if (isNaN(count) || count < 0 || !this.virtual) {
|
||||||
count = this._var.currentSource.length;
|
count = this._var.currentSource?.length ?? 0;
|
||||||
}
|
}
|
||||||
const cols = this.columns;
|
const cols = this.columns;
|
||||||
const content = this._var.refs.body;
|
const content = this._var.refs.body;
|
||||||
@ -1592,7 +1600,7 @@ export class Grid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onRowChanged(_e, index, col, value, cell, blur) {
|
_onRowChanged(e, index, col, value, cell, blur) {
|
||||||
if (this._var.currentSource == null) {
|
if (this._var.currentSource == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1610,9 +1618,12 @@ export class Grid {
|
|||||||
}
|
}
|
||||||
if (enabled !== false) {
|
if (enabled !== false) {
|
||||||
const val = item[col.key];
|
const val = item[col.key];
|
||||||
|
let oldValue;
|
||||||
if (val?.Value != null) {
|
if (val?.Value != null) {
|
||||||
|
oldValue = val.Value;
|
||||||
val.Value = value;
|
val.Value = value;
|
||||||
} else {
|
} else {
|
||||||
|
oldValue = val;
|
||||||
item[col.key] = value;
|
item[col.key] = value;
|
||||||
}
|
}
|
||||||
let tip = col.tooltip;
|
let tip = col.tooltip;
|
||||||
@ -1631,7 +1642,7 @@ export class Grid {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (typeof col.onChanged === 'function') {
|
if (typeof col.onChanged === 'function') {
|
||||||
col.onChanged.call(this, item, value);
|
col.onChanged.call(this, item, value, oldValue, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user