change: replace date controller of Scheduler.
feature: `ui.formatDate` supports formatter. fix: issue about boolean sort.
This commit is contained in:
@ -805,10 +805,32 @@ export class GridDateColumn extends GridColumn {
|
||||
* * `"1/26/2024"`
|
||||
* * `"638418240000000000"`
|
||||
* * `new Date('2024-01-26')`
|
||||
* @param {string} [formatter] - 格式化格式,默认为 `"m/d/Y"`
|
||||
*
|
||||
* * Y - 年,例如 `2024`
|
||||
* * y - 年的后两位,例如 `"24"`
|
||||
* * n - 月,例如 `2`
|
||||
* * m - 格式化成两位的月,例如 `"02"`
|
||||
* * j - 日,例如 `4`
|
||||
* * d - 格式化成两位的日,例如 `"04"`
|
||||
* * t - 日期当月总天数,例如 `29`
|
||||
* * L - 是否为闰年,例如 `1`
|
||||
* * G - 小时,例如 `15`
|
||||
* * g - 12 小时制的小时,例如 `3`
|
||||
* * H - 格式化成两位的小时,例如 `"15"`
|
||||
* * h - 格式化成两位的 12 小时制的小时,例如 `"03"`
|
||||
* * A - 上下午,例如 `"PM"`
|
||||
* * a - 小写的上下午,例如 `"pm"`
|
||||
* * i - 格式化成两位的分钟,例如 `"39"`
|
||||
* * s - 格式化成两位的秒,例如 `"20"`
|
||||
* * u - 格式化成六位的毫秒,例如 `"023040"`
|
||||
* * e - 时区描述字符串,例如 `"China Standard Time"`
|
||||
* * O - 时区偏移字符串,例如 `"+0800"`
|
||||
* * P - `"+08:00"` 这种格式的时区偏移字符串
|
||||
* @returns {string} 格式化为 M/d/yyyy 的日期字符串
|
||||
*/
|
||||
static formatDate(date) {
|
||||
return formatDate(date);
|
||||
static formatDate(date, formatter) {
|
||||
return formatDate(date, formatter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user