@@ -1642,18 +1642,6 @@ def put_datatable(
16421642
16431643 js_func_key = random_str (10 )
16441644
1645- def json_encoder (obj ):
1646- if isinstance (obj , JSFunction ):
1647- return dict (
1648- __pywebio_js_function__ = js_func_key ,
1649- params = obj .params ,
1650- body = obj .body ,
1651- )
1652- raise TypeError
1653-
1654- column_args = json .loads (json .dumps (column_args , default = json_encoder ))
1655- grid_args = json .loads (json .dumps (grid_args , default = json_encoder ))
1656-
16571645 def callback (data : Dict ):
16581646 rows = data ['rows' ] if multiple_select else data ['rows' ][0 ]
16591647
@@ -1671,6 +1659,19 @@ def callback(data: Dict):
16711659 field_args = {k : v for k , v in column_args .items () if isinstance (k , str )}
16721660 path_args = [(k , v ) for k , v in column_args .items () if not isinstance (k , str )]
16731661
1662+ def json_encoder (obj ):
1663+ if isinstance (obj , JSFunction ):
1664+ return dict (
1665+ __pywebio_js_function__ = js_func_key ,
1666+ params = obj .params ,
1667+ body = obj .body ,
1668+ )
1669+ raise TypeError
1670+
1671+ field_args = json .loads (json .dumps (field_args , default = json_encoder ))
1672+ path_args = json .loads (json .dumps (path_args , default = json_encoder ))
1673+ grid_args = json .loads (json .dumps (grid_args , default = json_encoder ))
1674+
16741675 if isinstance (column_order , (list , tuple )):
16751676 column_order = {k : None for k in column_order }
16761677
0 commit comments