Skip to content

Commit 52064e2

Browse files
author
Marius Conjeaud
committed
Fix compact x wrapping
1 parent c666767 commit 52064e2

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/chart/table/TableActionsHelper.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ export const getCheckboxes = (actionsRules, rows, getGlobalParameter) => {
1515
// If the parameter is an array (to be expected), iterate over it to find the rows to check.
1616
if (Array.isArray(values)) {
1717
values.forEach((value) => {
18-
rows.forEach((row, index) => {
18+
rows.forEach((row) => {
1919
if (row[fieldName] == value) {
20-
selection.push(index);
20+
selection.push(row.id);
2121
}
2222
});
2323
});
2424
} else {
2525
// Else (special case), still check the row if it's a single value parameter.
26-
rows.forEach((row, index) => {
26+
rows.forEach((row) => {
2727
if (row[fieldName] == values) {
28-
selection.push(index);
28+
selection.push(row.id);
2929
}
3030
});
3131
}
@@ -35,7 +35,8 @@ export const getCheckboxes = (actionsRules, rows, getGlobalParameter) => {
3535

3636
export const updateCheckBoxes = (actionsRules, rows, selection, setGlobalParameter) => {
3737
if (hasCheckboxes(actionsRules)) {
38-
const selectedRows = rows.filter((_, i) => selection.includes(i));
38+
const selectedRows = rows.filter((row) => selection.includes(row.id));
39+
console.log(selectedRows);
3940
let rules = actionsRules.filter((rule) => rule.condition && rule.condition == 'rowCheck');
4041
rules.forEach((rule) => {
4142
const parameterValues = selectedRows.map((row) => row[rule.value]).filter((v) => v !== undefined);

src/chart/table/TableChart.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import Button from '@mui/material/Button';
2424
import { extensionEnabled } from '../../utils/ReportUtils';
2525
import { getCheckboxes, hasCheckboxes, updateCheckBoxes } from './TableActionsHelper';
2626

27-
const TABLE_HEADER_HEIGHT = 32;
28-
const TABLE_FOOTER_HEIGHT = 62;
2927
const TABLE_ROW_HEIGHT = 52;
3028
const HIDDEN_COLUMN_PREFIX = '__';
3129
const theme = createTheme({
@@ -209,10 +207,13 @@ export const NeoTableChart = (props: ChartProps) => {
209207
});
210208

211209
const pageNames = getPageNumbersAndNamesList();
210+
const customStyles = { '&.MuiDataGrid-root .MuiDataGrid-footerContainer > div': { marginTop: '0px' } };
211+
212212
const commonGridProps = {
213213
key: 'tableKey',
214214
columnHeaderHeight: 32,
215-
density: compact ? 'compact' : 'standard',
215+
rowHeight: tableRowHeight,
216+
autoPageSize: true,
216217
rows: rows,
217218
columns: columns,
218219
columnVisibilityModel: columnVisibilityModel,
@@ -230,7 +231,6 @@ export const NeoTableChart = (props: ChartProps) => {
230231
checkboxSelection: hasCheckboxes(actionsRules),
231232
rowSelectionModel: getCheckboxes(actionsRules, rows, props.getGlobalParameter),
232233
onRowSelectionModelChange: (selection) => updateCheckBoxes(actionsRules, rows, selection, props.setGlobalParameter),
233-
autoPageSize: true,
234234
disableRowSelectionOnClick: true,
235235
components: {
236236
ColumnSortedDescendingIcon: () => <></>,
@@ -301,15 +301,12 @@ export const NeoTableChart = (props: ChartProps) => {
301301
{...commonGridProps}
302302
getRowHeight={() => 'auto'}
303303
sx={{
304-
'&.MuiDataGrid-root--densityCompact .MuiDataGrid-cell': { py: '3px' },
305-
'&.MuiDataGrid-root--densityCompact .MuiDataGrid-cell:has(button)': { py: '0px' },
306-
'&.MuiDataGrid-root--densityStandard .MuiDataGrid-cell': { py: '15px' },
307-
'&.MuiDataGrid-root--densityComfortable .MuiDataGrid-cell': { py: '22px' },
304+
...customStyles,
308305
'&.MuiDataGrid-root .MuiDataGrid-cell': { wordBreak: 'break-word' },
309306
}}
310307
/>
311308
) : (
312-
<DataGrid {...commonGridProps} rowHeight={tableRowHeight} />
309+
<DataGrid {...commonGridProps} sx={customStyles} />
313310
)}
314311
</div>
315312
</ThemeProvider>

src/index.pcss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@
7474
@apply n-ml-token-3;
7575
}
7676

77+
/* DataGrid overrides */
78+
.MuiDataGrid-footerContainer > div {
79+
@apply n-mt-0;
80+
}
81+
7782
/* Make bullet list points in Markdown card view */
7883
.card-view ul {
7984
@apply n-list-disc n-ml-token-7;

0 commit comments

Comments
 (0)