Skip to content

Commit

Permalink
add autosize
Browse files Browse the repository at this point in the history
  • Loading branch information
ddecrulle committed Dec 4, 2024
1 parent 91a89c2 commit 9268809
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion web/src/ui/pages/dataExplorer/DataExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import { declareComponentKeys, useTranslation } from "ui/i18n";
import type { Link } from "type-route";
import { useOnOpenBrowserSearch } from "ui/tools/useOnOpenBrowserSearch";
import { env } from "env";
import { CustomDataGrid } from "ui/shared/Datagrid/CustomDataGrid";
import { autosizeOptions, CustomDataGrid } from "ui/shared/Datagrid/CustomDataGrid";
import { SlotsDataGridToolbar } from "./SlotsDataGridToolbar";
import { exclude } from "tsafe/exclude";
import { useApplyClassNameToParent } from "ui/tools/useApplyClassNameToParent";
import { useGridApiRef } from "@mui/x-data-grid";

export type Props = {
route: PageRoute;
Expand All @@ -29,6 +30,8 @@ export default function DataExplorer(props: Props) {
const { dataExplorer } = useCore().functions;
const { t } = useTranslation({ DataExplorer });

const apiRef = useGridApiRef();

useEffect(() => {
dataExplorer.initialize({
sourceUrl: route.params.source ?? "",
Expand Down Expand Up @@ -58,6 +61,12 @@ export default function DataExplorer(props: Props) {
isQuerying
} = useCoreState("dataExplorer", "main");

useEffect(() => {
if (columns) {
apiRef.current.autosizeColumns(autosizeOptions);
}
}, [columns]);

useEffect(() => {
if (queryParams === undefined) {
routes[route.name]().replace();
Expand Down Expand Up @@ -151,6 +160,7 @@ export default function DataExplorer(props: Props) {
return (
<div className={cx(classes.dataGridWrapper, className)}>
<CustomDataGrid
apiRef={apiRef}
shouldAddCopyToClipboardInCell
classes={{
panelWrapper: cx(
Expand Down

0 comments on commit 9268809

Please sign in to comment.