mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
prevent grid rerender when celldata is not changed
This commit is contained in:
parent
2cd2546f3f
commit
f60ee04883
@ -27,13 +27,14 @@ export default function DataGrid(props) {
|
||||
const [selection, setSelection] = React.useState([]);
|
||||
const [formSelection, setFormSelection] = React.useState(null);
|
||||
const [grider, setGrider] = React.useState(null);
|
||||
const [collapsedWidgets, setCollapsedWidgets] = React.useState([]);
|
||||
// const [formViewData, setFormViewData] = React.useState(null);
|
||||
const isFormView = !!(config && config.isFormView);
|
||||
|
||||
return (
|
||||
<HorizontalSplitter initialValue="300px" size={managerSize} setSize={setManagerSize}>
|
||||
<LeftContainer theme={theme}>
|
||||
<WidgetColumnBar>
|
||||
<WidgetColumnBar onChangeCollapsedWidgets={setCollapsedWidgets}>
|
||||
{!isFormView && (
|
||||
<WidgetColumnBarItem title="Columns" name="columns" height={props.showReferences ? '40%' : '60%'}>
|
||||
<ColumnManager {...props} managerSize={managerSize} />
|
||||
@ -44,7 +45,7 @@ export default function DataGrid(props) {
|
||||
<ReferenceManager {...props} managerSize={managerSize} />
|
||||
</WidgetColumnBarItem>
|
||||
)}
|
||||
<WidgetColumnBarItem title="Cell data" name="cellData" collapsed={props.isDetailView}>
|
||||
<WidgetColumnBarItem title="Cell data" name="cellData" collapsed>
|
||||
{isFormView ? (
|
||||
<CellDataView selectedValue={formSelection} />
|
||||
) : (
|
||||
@ -60,7 +61,7 @@ export default function DataGrid(props) {
|
||||
) : (
|
||||
<GridCore
|
||||
{...props}
|
||||
onSelectionChanged={setSelection}
|
||||
onSelectionChanged={collapsedWidgets.includes('cellData') ? null : setSelection}
|
||||
onChangeGrider={setGrider}
|
||||
formViewAvailable={!!FormView && !!formDisplay}
|
||||
/>
|
||||
|
@ -40,7 +40,7 @@ function WidgetContainer({ widget, visible, splitterVisible, parentHeight, initi
|
||||
);
|
||||
}
|
||||
|
||||
export default function WidgetColumnBar({ children }) {
|
||||
export default function WidgetColumnBar({ children, onChangeCollapsedWidgets = undefined }) {
|
||||
const childArray = _.isArray(children) ? children : [children];
|
||||
const [refNode, dimensions] = useDimensions();
|
||||
const [collapsedWidgets, setCollapsedWidgets] = React.useState(() =>
|
||||
@ -53,6 +53,9 @@ export default function WidgetColumnBar({ children }) {
|
||||
if (collapsedWidgets.includes(name)) setCollapsedWidgets(collapsedWidgets.filter((x) => x != name));
|
||||
else setCollapsedWidgets([...collapsedWidgets, name]);
|
||||
};
|
||||
React.useEffect(() => {
|
||||
if (onChangeCollapsedWidgets) onChangeCollapsedWidgets(collapsedWidgets);
|
||||
}, [onChangeCollapsedWidgets, collapsedWidgets]);
|
||||
|
||||
return (
|
||||
<WidgetsMainContainer ref={refNode}>
|
||||
|
Loading…
Reference in New Issue
Block a user