Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Using qEffectiveInterColumnSortOrder to fetch right index in qmatrix
Browse files Browse the repository at this point in the history
  • Loading branch information
Helene Rigner committed May 16, 2019
1 parent 8a4f3c1 commit 024943a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/components/hypercube-table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,31 @@ import useResolvedValue from './use/resolved-value';

import './hypercube-table.pcss';

function cellGetterForIndex(index) {
function cellGetterForIndex(index, layout) {
return function cellGetter({ rowData }) {
if (!rowData || !rowData[index]) {
const indexInQMatrix = layout.qHyperCube.qEffectiveInterColumnSortOrder.indexOf(index);
if (!rowData || !rowData[indexInQMatrix]) {
return '';
}
return rowData[index].qText;
return rowData[indexInQMatrix].qText;
};
}

function cellRendererForIndex(index) {
function cellRendererForIndex(index, layout) {
function cellRenderer({ rowData }) {
if (!rowData || !rowData[index]) {
const indexInQMatrix = layout.qHyperCube.qEffectiveInterColumnSortOrder.indexOf(index);
if (!rowData || !rowData[indexInQMatrix]) {
return (<div>...</div>);
}
let title;
if (!rowData[index].qNum || rowData[index].qNum === 'NaN') {
title = `'${rowData[index].qText || ''}' (No numerical representation)`;
if (!rowData[indexInQMatrix].qNum || rowData[indexInQMatrix].qNum === 'NaN') {
title = `'${rowData[indexInQMatrix].qText || ''}' (No numerical representation)`;
} else {
title = `'${rowData[index].qText}' (Numerical representation: ${rowData[index].qNum})`;
title = `'${rowData[indexInQMatrix].qText}' (Numerical representation: ${rowData[indexInQMatrix].qNum})`;
}
return (
<div title={title}>
{rowData[index].qText ? rowData[index].qText : '< empty >'}
{rowData[indexInQMatrix].qText ? rowData[indexInQMatrix].qText : '< empty >'}
</div>
);
}
Expand Down Expand Up @@ -183,8 +185,8 @@ export default function HypercubeTable({
key={dim.title}
width={getDimensionWidth(layout, dimensionIndex, dim.title)}
flexGrow={1}
cellDataGetter={cellGetterForIndex(dimensionIndex)}
cellRenderer={cellRendererForIndex(dimensionIndex)}
cellDataGetter={cellGetterForIndex(dimensionIndex, layout)}
cellRenderer={cellRendererForIndex(dimensionIndex, layout)}
headerRenderer={columnHeaderRenderer}
/>
))
Expand All @@ -198,8 +200,8 @@ export default function HypercubeTable({
columnData={measure}
key={measure.title}
flexGrow={1}
cellDataGetter={cellGetterForIndex(dimensions.length + measureIndex)}
cellRenderer={cellRendererForIndex(dimensions.length + measureIndex)}
cellDataGetter={cellGetterForIndex(dimensions.length + measureIndex, layout)}
cellRenderer={cellRendererForIndex(dimensions.length + measureIndex, layout)}
headerRenderer={columnHeaderRenderer}
/>
))
Expand Down
4 changes: 4 additions & 0 deletions src/components/hypercube-table.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,8 @@
.ReactVirtualized__Table__rowColumn:last-of-type {
border-right: none;
}

.ReactVirtualized__Table__headerRow {
text-transform: none;
}
}

0 comments on commit 024943a

Please sign in to comment.