add: column.filterAsValue

fix: case-sensitive order of Array value
This commit is contained in:
Chen Lily 2024-03-27 13:36:31 +08:00
parent c78e445a24
commit 03e3b4a70f
2 changed files with 38 additions and 24 deletions

View File

@ -255,6 +255,7 @@ let r = lang;
* @property {any[]} [filterValues] - 过滤值的数组 * @property {any[]} [filterValues] - 过滤值的数组
* @property {boolean} [filterAllowNull=false] - 是否区分 `null` 与空字符串 * @property {boolean} [filterAllowNull=false] - 是否区分 `null` 与空字符串
* @property {(ValueItem[] | GridColumnFilterSourceCallback)} [filterSource] - 自定义列过滤器的数据源支持调用函数返回数据源 * @property {(ValueItem[] | GridColumnFilterSourceCallback)} [filterSource] - 自定义列过滤器的数据源支持调用函数返回数据源
* @property {boolean} [filterAsValue=false] - 列头过滤强制使用 `Value` 字段
* @property {GridItemSortCallback} [sortFilter] - 自定义列排序函数 * @property {GridItemSortCallback} [sortFilter] - 自定义列排序函数
* @property {DropdownOptions} [dropOptions] - 列为下拉列表类型时以该值设置下拉框的参数 * @property {DropdownOptions} [dropOptions] - 列为下拉列表类型时以该值设置下拉框的参数
* @property {(GridSourceItem[] | Promise<GridSourceItem[]> | GridDropdownSourceCallback)} [source] - 列为下拉列表类型时以该值设置下拉列表数据源支持返回异步对象也支持调用函数返回 * @property {(GridSourceItem[] | Promise<GridSourceItem[]> | GridDropdownSourceCallback)} [source] - 列为下拉列表类型时以该值设置下拉列表数据源支持返回异步对象也支持调用函数返回
@ -2265,10 +2266,18 @@ export class Grid {
b = 0; b = 0;
} else if (a != null && b == null) { } else if (a != null && b == null) {
return direction; return direction;
} else if (typeof a === 'string' && typeof b === 'string') { } else {
if (Array.isArray(a)) {
a = a.join(', ');
}
if (Array.isArray(b)) {
b = b.join(', ');
}
if (typeof a === 'string' && typeof b === 'string') {
a = a.toLowerCase(); a = a.toLowerCase();
b = b.toLowerCase(); b = b.toLowerCase();
} }
}
return a === b ? 0 : (a > b ? 1 : -1) * direction; return a === b ? 0 : (a > b ? 1 : -1) * direction;
}; };
} }
@ -3489,25 +3498,30 @@ export class Grid {
}; };
} }
} }
const filterAsValue = col.filterAsValue;
array = Object.values(dict) array = Object.values(dict)
.sort((a, b) => { .sort((itemA, itemB) => {
// if (a == null && b == null) { let a = itemA.Value;
// return 0; let b = itemB.Value;
// } if (a instanceof Date || b instanceof Date) {
// if (a == null && b != null) { if (a == null) {
// return -1; a = 0;
// } } else if (b == null) {
// if (a != null && b == null) { b = 0;
// return 1; }
// } } else if (a != null && b == null) {
// if (Object.prototype.hasOwnProperty.call(a, 'Value')) { return 1;
// a = a.Value; } else {
// } if (!filterAsValue) {
// if (Object.prototype.hasOwnProperty.call(b, 'Value')) { a = itemA.DisplayValue;
// b = b.Value; b = itemB.DisplayValue;
// } }
// return a > b ? 1 : a < b ? -1 : 0; if (typeof a === 'string' && typeof b === 'string') {
return a.Value > b.Value ? 1 : a.Value < b.Value ? -1 : 0; a = a.toLowerCase();
b = b.toLowerCase();
}
}
return a > b ? 1 : (a < b ? -1 : 0);
}); });
} }
array = array.map(i => { array = array.map(i => {

6
package-lock.json generated
View File

@ -2041,9 +2041,9 @@
} }
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.4.715", "version": "1.4.717",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.715.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.717.tgz",
"integrity": "sha512-XzWNH4ZSa9BwVUQSDorPWAUQ5WGuYz7zJUNpNif40zFCiCl20t8zgylmreNmn26h5kiyw2lg7RfTmeMBsDklqg==", "integrity": "sha512-6Fmg8QkkumNOwuZ/5mIbMU9WI3H2fmn5ajcVya64I5Yr5CcNmO7vcLt0Y7c96DCiMO5/9G+4sI2r6eEvdg1F7A==",
"dev": true "dev": true
}, },
"node_modules/entities": { "node_modules/entities": {