change: replace date controller of Scheduler.

feature: `ui.formatDate` supports formatter.
fix: issue about boolean sort.
This commit is contained in:
2024-03-28 16:37:22 +08:00
parent 03e3b4a70f
commit 0ff48a0ac4
6 changed files with 197 additions and 1689 deletions

View File

@ -2260,6 +2260,12 @@ export class Grid {
return (a, b) => {
a = this._getItemProp(a.values, true, col);
b = this._getItemProp(b.values, true, col);
if (typeof a === 'boolean') {
a = a ? 2 : 1;
}
if (typeof b === 'boolean') {
b = b ? 2 : 1;
}
if (a == null && typeof b === 'number') {
a = 0;
} else if (typeof a === 'number' && b == null) {
@ -3499,6 +3505,8 @@ export class Grid {
}
}
const filterAsValue = col.filterAsValue;
const type = this._var.colTypes[col.key];
const isDateColumn = type === GridDateColumn || type instanceof GridDateColumn;
array = Object.values(dict)
.sort((itemA, itemB) => {
let a = itemA.Value;
@ -3512,7 +3520,7 @@ export class Grid {
} else if (a != null && b == null) {
return 1;
} else {
if (!filterAsValue) {
if (!filterAsValue && !isDateColumn) {
a = itemA.DisplayValue;
b = itemB.DisplayValue;
}
@ -3654,7 +3662,7 @@ export class Grid {
const display = Object.prototype.hasOwnProperty.call(item, 'DisplayValue') ? item.DisplayValue : item;
div.appendChild(createCheckbox({
checked: item.__checked,
label: display && String(display).replace(/(\r\n|\n|<br[ \t]*\/?>)/g, '\u00a0'),
label: display && String(display).replace(/( |\r\n|\n|<br[ \t]*\/?>)/g, '\u00a0'),
title: display,
onchange: e => {
item.__checked = e.target.checked;