From 1bf8a068cf85ff20432ac3596562e321667f786c Mon Sep 17 00:00:00 2001 From: Andrew Cherniavskyi Date: Thu, 22 May 2025 01:07:29 +0200 Subject: [PATCH] fix filtering by size not working --- .../aggregation/AggregationTreeData.js | 21 ++++++------------- .../aggregation/AggregationTreeData.tsx | 21 ++++++------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/docs/data/data-grid/aggregation/AggregationTreeData.js b/docs/data/data-grid/aggregation/AggregationTreeData.js index 78fcd77ea2689..b8d0f44829c0a 100644 --- a/docs/data/data-grid/aggregation/AggregationTreeData.js +++ b/docs/data/data-grid/aggregation/AggregationTreeData.js @@ -89,24 +89,15 @@ const columns = [ field: 'size', headerName: 'Size', type: 'number', - valueFormatter: (value) => { + valueGetter: (value) => { if (value == null) { - return ''; - } - if (value < 100) { - return `${value} b`; - } - - if (value < 1_000_000) { - return `${Math.floor(value / 100) / 10} Kb`; + return 0; } - - if (value < 1_000_000_000) { - return `${Math.floor(value / 100_000) / 10} Mb`; - } - - return `${Math.floor(value / 100_000_000) / 10} Gb`; + const sizeInKb = value / 1024; + // Round to 2 decimal places + return Math.round(sizeInKb * 100) / 100; }, + valueFormatter: (value) => `${value} Kb`, }, { field: 'updatedAt', diff --git a/docs/data/data-grid/aggregation/AggregationTreeData.tsx b/docs/data/data-grid/aggregation/AggregationTreeData.tsx index 3d4c05667a185..dd41097a7b2d5 100644 --- a/docs/data/data-grid/aggregation/AggregationTreeData.tsx +++ b/docs/data/data-grid/aggregation/AggregationTreeData.tsx @@ -101,24 +101,15 @@ const columns: GridColDef[] = [ field: 'size', headerName: 'Size', type: 'number', - valueFormatter: (value) => { + valueGetter: (value) => { if (value == null) { - return ''; - } - if (value < 100) { - return `${value} b`; - } - - if (value < 1_000_000) { - return `${Math.floor(value / 100) / 10} Kb`; + return 0; } - - if (value < 1_000_000_000) { - return `${Math.floor(value / 100_000) / 10} Mb`; - } - - return `${Math.floor(value / 100_000_000) / 10} Gb`; + const sizeInKb = value / 1024; + // Round to 2 decimal places + return Math.round(sizeInKb * 100) / 100; }, + valueFormatter: (value) => `${value} Kb`, }, { field: 'updatedAt',