diff --git a/packages/s2-core/src/facet/layout/build-gird-hierarchy.ts b/packages/s2-core/src/facet/layout/build-gird-hierarchy.ts index 7f93971c9e..53864399f3 100644 --- a/packages/s2-core/src/facet/layout/build-gird-hierarchy.ts +++ b/packages/s2-core/src/facet/layout/build-gird-hierarchy.ts @@ -23,9 +23,8 @@ const buildTotalGridHierarchy = (params: GridHeaderParams) => { const { dataSet, values, spreadsheet } = facetCfg; const fieldValues: FieldValue[] = []; - const fieldName = dataSet.getFieldName(currentField); - let query = {}; + let query: Record = {}; const totalsConfig = spreadsheet.getTotalsConfig(currentField); const dimensionGroup = parentNode.isGrandTotals ? totalsConfig.totalsGroupDimensions @@ -44,8 +43,8 @@ const buildTotalGridHierarchy = (params: GridHeaderParams) => { }), ), ); - if (isEmpty(fieldValues)) { - fieldValues.push(fieldName); + if (isEmpty(fieldValues) && currentField) { + fieldValues.push(EMPTY_FIELD_VALUE); } } else if (addTotalMeasureInTotal && currentField === EXTRA_FIELD) { // add total measures @@ -98,7 +97,7 @@ const buildNormalGridHierarchy = (params: GridHeaderParams) => { // add skeleton for empty data - if (isEmpty(fieldValues)) { + if (isEmpty(fieldValues) && currentField) { if (currentField === EXTRA_FIELD) { fieldValues.push(...dataSet.fields?.values); } else {