add docs
This commit is contained in:
@ -29,6 +29,8 @@ export class GridColumn {
|
||||
tooltip.style.display = enabled === false ? 'none' : '';
|
||||
}
|
||||
}
|
||||
|
||||
static toString() { return '[object Column]' }
|
||||
}
|
||||
|
||||
export class GridInputColumn extends GridColumn {
|
||||
@ -109,8 +111,8 @@ export class GridDropdownColumn extends GridColumn {
|
||||
wrapper
|
||||
});
|
||||
drop.onselected = trigger;
|
||||
if (typeof col.dropExpanded === 'function') {
|
||||
drop.onexpanded = col.dropExpanded.bind(col, it.values, drop);
|
||||
if (typeof col.onDropExpanded === 'function') {
|
||||
drop.onexpanded = col.onDropExpanded.bind(col, it.values, drop);
|
||||
}
|
||||
return drop.create();
|
||||
}
|
||||
@ -225,7 +227,7 @@ export class GridIconColumn extends GridColumn {
|
||||
static create() { return createElement('span', 'col-icon') }
|
||||
|
||||
static setValue(element, val, item, col, _grid) {
|
||||
let className = col.className;
|
||||
let className = col.iconClassName;
|
||||
if (typeof className === 'function') {
|
||||
className = className.call(col, item.values);
|
||||
}
|
||||
@ -257,4 +259,47 @@ export class GridIconColumn extends GridColumn {
|
||||
element.classList.remove('disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class GridDateColumn extends GridColumn {
|
||||
static createEdit(trigger, col) {
|
||||
const date = createElement('input', 'ui-grid-date-cell');
|
||||
date.required = true;
|
||||
date.type = 'date';
|
||||
if (col.dateMin != null) {
|
||||
date.min = col.dateMin;
|
||||
}
|
||||
if (col.dateMax != null) {
|
||||
date.max = col.dateMax;
|
||||
}
|
||||
date.addEventListener('change', trigger);
|
||||
return date;
|
||||
}
|
||||
|
||||
static setValue(element, val) {
|
||||
if (element.tagName === 'INPUT') {
|
||||
if (isNaN(val) || /^\d{4}-\d{2}-\d{2}$/.test(val)) {
|
||||
element.value = val;
|
||||
} else {
|
||||
val = new Date((val - 621355968e9) / 10000);
|
||||
const month = String(val.getMonth() + 1).padStart(2, '0');
|
||||
const date = String(val.getDate()).padStart(2, '0');
|
||||
element.value = `${val.getFullYear()}-${month}-${date}`;
|
||||
}
|
||||
} else {
|
||||
element.innerText = val;
|
||||
}
|
||||
}
|
||||
|
||||
static getValue(e) {
|
||||
return e.target?.value;
|
||||
}
|
||||
|
||||
static setEnabled(element, enabled) {
|
||||
element.disabled = enabled === false;
|
||||
}
|
||||
|
||||
static formatDate(date) {
|
||||
return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user