@@ -46,6 +46,7 @@ def register_edits(ctx: ServerContext):
4646 _save_status_to_db = ctx ._save_status_to_db
4747 load_modifications_log = ctx .load_modifications_log
4848 load_data_from_source = ctx .load_data_from_source
49+ _cached_page_data = ctx ._cached_page_data
4950
5051 @render .ui
5152 def approval_status_ui ():
@@ -87,12 +88,16 @@ def _handle_cell_edit():
8788 row , col , old_val , new_val = process_cell_edit_action (edit_data )
8889 print (f"DEBUG: processed edit - row={ row } , col={ col } , old={ old_val } , new={ new_val } " )
8990 if row is not None and col :
90- current_df = data .get ()
91+ if is_lazy_loading () and _cached_page_data :
92+ current_df , _ , _ , _ = _cached_page_data ()
93+ else :
94+ current_df = data .get ()
9195 current_log = mods_log .get ()
9296 print (f"DEBUG: config type={ type (config )} , db_mode={ config .app_config .database .mode if hasattr (config , 'app_config' ) else 'N/A' } " )
9397 updated_df , updated_log = perform_cell_edit (current_df , current_log , row , col , old_val , new_val , config_instance = config )
9498 print (f"DEBUG: perform_cell_edit returned, log entries: { len (updated_log )} " )
95- data .set (updated_df )
99+ if not is_lazy_loading ():
100+ data .set (updated_df )
96101 mods_log .set (updated_log )
97102
98103 pk_cols = app_config .table .primary_key
@@ -118,7 +123,10 @@ def _handle_cell_edit():
118123 print (f"Warning: Could not track edited cell: { e } " )
119124
120125 save_log_to_file (updated_log , modifications_log_path )
121- updated_df .to_json (data_dir / "data_state.json" , orient = "records" , indent = 2 , default_handler = str )
126+ if not is_lazy_loading ():
127+ updated_df .to_json (data_dir / "data_state.json" , orient = "records" , indent = 2 , default_handler = str )
128+ else :
129+ _table_reload_trigger .set (_table_reload_trigger .get () + 1 )
122130 col_label = f"{ col } → { target_col } " if target_col != col else col
123131 ui .notification_show (f"Updated Row { row + 1 } , { col_label } " , type = "message" , duration = 2 )
124132
0 commit comments