igniteui-angular 13.0.2 → 13.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2389,6 +2389,7 @@ DefaultSortingStrategy._instance = null;
|
|
|
2389
2389
|
const DATE_TYPE = 'date';
|
|
2390
2390
|
const TIME_TYPE = 'time';
|
|
2391
2391
|
const DATE_TIME_TYPE = 'dateTime';
|
|
2392
|
+
const STRING_TYPE = 'string';
|
|
2392
2393
|
class IgxSorting {
|
|
2393
2394
|
sort(data, expressions, grid) {
|
|
2394
2395
|
return this.sortDataRecursive(data, expressions, 0, grid);
|
|
@@ -2402,7 +2403,8 @@ class IgxSorting {
|
|
|
2402
2403
|
const column = grid ? grid.getColumnByName(expressions[level].fieldName) : null;
|
|
2403
2404
|
const isDate = column?.dataType === DATE_TYPE || column?.dataType === DATE_TIME_TYPE;
|
|
2404
2405
|
const isTime = column?.dataType === TIME_TYPE;
|
|
2405
|
-
const
|
|
2406
|
+
const isString = column?.dataType === STRING_TYPE;
|
|
2407
|
+
const group = this.groupedRecordsByExpression(data, i, expressions[level], isDate, isString);
|
|
2406
2408
|
const groupRow = {
|
|
2407
2409
|
expression: expressions[level],
|
|
2408
2410
|
level,
|
|
@@ -2456,16 +2458,22 @@ class IgxSorting {
|
|
|
2456
2458
|
}
|
|
2457
2459
|
return resolvedValue;
|
|
2458
2460
|
}
|
|
2459
|
-
groupedRecordsByExpression(data, index, expression, isDate = false) {
|
|
2461
|
+
groupedRecordsByExpression(data, index, expression, isDate = false, isString) {
|
|
2460
2462
|
const res = [];
|
|
2461
2463
|
const key = expression.fieldName;
|
|
2462
2464
|
const len = data.length;
|
|
2463
|
-
|
|
2465
|
+
let groupval = this.getFieldValue(data[index], key, isDate);
|
|
2464
2466
|
res.push(data[index]);
|
|
2465
2467
|
index++;
|
|
2466
2468
|
const comparer = expression.groupingComparer || DefaultSortingStrategy.instance().compareValues;
|
|
2467
2469
|
for (let i = index; i < len; i++) {
|
|
2468
|
-
|
|
2470
|
+
let fieldValue = this.getFieldValue(data[i], key, isDate);
|
|
2471
|
+
if (expression.ignoreCase && isString) {
|
|
2472
|
+
// when column's dataType is string but the value is number
|
|
2473
|
+
fieldValue = fieldValue?.toString().toLowerCase();
|
|
2474
|
+
groupval = groupval?.toString().toLowerCase();
|
|
2475
|
+
}
|
|
2476
|
+
if (comparer(fieldValue, groupval) === 0) {
|
|
2469
2477
|
res.push(data[i]);
|
|
2470
2478
|
}
|
|
2471
2479
|
else {
|
|
@@ -2492,13 +2500,14 @@ class IgxSorting {
|
|
|
2492
2500
|
const column = grid?.getColumnByName(expr.fieldName);
|
|
2493
2501
|
const isDate = column?.dataType === DATE_TYPE || column?.dataType === DATE_TIME_TYPE;
|
|
2494
2502
|
const isTime = column?.dataType === TIME_TYPE;
|
|
2503
|
+
const isString = column?.dataType === STRING_TYPE;
|
|
2495
2504
|
data = expr.strategy.sort(data, expr.fieldName, expr.dir, expr.ignoreCase, this.getFieldValue, isDate, isTime);
|
|
2496
2505
|
if (expressionIndex === exprsLen - 1) {
|
|
2497
2506
|
return data;
|
|
2498
2507
|
}
|
|
2499
2508
|
// in case of multiple sorting
|
|
2500
2509
|
for (i = 0; i < dataLen; i++) {
|
|
2501
|
-
gbData = this.groupedRecordsByExpression(data, i, expr, isDate);
|
|
2510
|
+
gbData = this.groupedRecordsByExpression(data, i, expr, isDate, isString);
|
|
2502
2511
|
gbDataLen = gbData.length;
|
|
2503
2512
|
if (gbDataLen > 1) {
|
|
2504
2513
|
gbData = this.sortDataRecursive(gbData, expressions, expressionIndex + 1, grid);
|