1
0
namnguyen 6 сар өмнө
parent
commit
661b98630a

+ 16 - 7
doc/gui/extension/example_library/front-end/src/BasicTable.tsx

@@ -14,18 +14,18 @@ interface BasicTableProps extends TaipyDynamicProps {
     data: TableValueType;
     data: TableValueType;
 }
 }
 
 
+const pageKey = "no-page-key";
+
 const BasicTable = (props: BasicTableProps) => {
 const BasicTable = (props: BasicTableProps) => {
     const { data, updateVarName = "", updateVars = "", id } = props;
     const { data, updateVarName = "", updateVars = "", id } = props;
     const [value, setValue] = useState<TableValueType>({});
     const [value, setValue] = useState<TableValueType>({});
-    const pageKey = useRef("no-page-key");
     const dispatch = useDispatch();
     const dispatch = useDispatch();
     const module = useModule();
     const module = useModule();
     const refresh = data?.__taipy_refresh !== undefined;
     const refresh = data?.__taipy_refresh !== undefined;
     useDispatchRequestUpdateOnFirstRender(dispatch, id, module, updateVars);
     useDispatchRequestUpdateOnFirstRender(dispatch, id, module, updateVars);
 
 
-    const [colsOrder] = useMemo(() => {
-        const colsOrder = Object.keys(value || {});
-        return [colsOrder, value || {}];
+    const colsOrder = useMemo(() => {
+        return Object.keys(value || {});
     }, [value]);
     }, [value]);
 
 
     const rows = useMemo(() => {
     const rows = useMemo(() => {
@@ -44,12 +44,21 @@ const BasicTable = (props: BasicTableProps) => {
     }, [value, colsOrder]);
     }, [value, colsOrder]);
 
 
     useEffect(() => {
     useEffect(() => {
-        if (refresh || !data) {
+        if (refresh || !data || data[pageKey] === undefined) {
             dispatch(
             dispatch(
-                createRequestDataUpdateAction(updateVarName, id, module, colsOrder, pageKey.current, {}, true, "ExampleLibrary")
+                createRequestDataUpdateAction(
+                    updateVarName,
+                    id,
+                    module,
+                    colsOrder,
+                    pageKey,
+                    {},
+                    true,
+                    "ExampleLibrary",
+                ),
             );
             );
         } else {
         } else {
-            setValue(data[pageKey.current]);
+            setValue(data[pageKey]);
         }
         }
     }, [refresh, data, colsOrder, updateVarName, id, dispatch, module]);
     }, [refresh, data, colsOrder, updateVarName, id, dispatch, module]);
 
 

+ 1 - 1
doc/gui/extension/table_data.py

@@ -15,7 +15,7 @@ chessboard = [
 ]
 ]
 
 
 # Create a DataFrame to represent the chessboard
 # Create a DataFrame to represent the chessboard
-data = pd.DataFrame(chessboard, index=[8, 7, 6, 5, 4, 3, 2, 1], columns=["A", "B", "C", "D", "E", "F", "G", "H"])
+data = pd.DataFrame(chessboard, columns=["A", "B", "C", "D", "E", "F", "G", "H"])
 
 
 page = """
 page = """
 ## Chess Game
 ## Chess Game