77import json
88from typing import Any , ClassVar , Generic , Type
99
10+ import reflex as rx
1011from fastapi import Request
1112from sqlmodel import col , func , select
1213
13- import reflex as rx
14-
15- from reflex_ag_grid .ag_grid import ag_grid , ColumnDef
14+ from reflex_ag_grid .ag_grid import ColumnDef , ag_grid
1615from reflex_ag_grid .datasource import Datasource
17- from reflex_ag_grid .handlers import apply_filter_model , apply_sort_model , M
16+ from reflex_ag_grid .handlers import M , apply_filter_model , apply_sort_model
1817
1918
2019def _value_setter_signature (
@@ -41,12 +40,12 @@ def get_default_column_def(
4140 Returns:
4241 The column definition.
4342 """
44- _cdef_kwargs = dict (
45- sortable = True ,
46- filter = True ,
47- editable = True if value_setter is not None else False ,
48- cell_editor = ag_grid .editors .text ,
49- )
43+ _cdef_kwargs = {
44+ " sortable" : True ,
45+ " filter" : True ,
46+ " editable" : value_setter is not None ,
47+ " cell_editor" : ag_grid .editors .text ,
48+ }
5049 _cdef_kwargs .update (cdef_kwargs )
5150 cdef = ag_grid .column_def (
5251 field = field ,
@@ -100,17 +99,17 @@ def _add_data_route(cls):
10099 The backend route will call the _get_data method to fetch the data.
101100 """
102101 app = rx .utils .prerequisites .get_app ().app
103- if cls .__data_route__ in app .api .routes :
102+ if cls .__data_route__ in app ._api .routes :
104103 return
105104
106- @app .api .get (cls .__data_route__ )
105+ @app ._api .get (cls .__data_route__ )
107106 async def get_data (
108107 request : Request ,
109108 state : str ,
110109 start : int ,
111110 end : int ,
112- filter_model : str = None ,
113- sort_model : str = None ,
111+ filter_model : str | None = None ,
112+ sort_model : str | None = None ,
114113 ):
115114 try :
116115 token = request .headers ["X-Reflex-Client-Token" ]
@@ -204,13 +203,13 @@ def get_component(cls, *children, **props) -> rx.Component:
204203 Returns:
205204 The Ag-Grid component.
206205 """
207- _props = dict (
208- id = f"ag-grid-{ cls .get_full_name ()} " ,
209- default_col_def = {"flex" : 1 },
210- max_blocks_in_cache = 4 ,
211- cache_block_size = 50 ,
212- group_default_expanded = None ,
213- )
206+ _props = {
207+ "id" : f"ag-grid-{ cls .get_full_name ()} " ,
208+ " default_col_def" : {"flex" : 1 },
209+ " max_blocks_in_cache" : 4 ,
210+ " cache_block_size" : 50 ,
211+ " group_default_expanded" : None ,
212+ }
214213 _props .update (props )
215214 return ag_grid .root (
216215 * children ,
@@ -333,7 +332,7 @@ def _get_column_defs(self) -> list[ColumnDef]:
333332 field = field .name ,
334333 ftype = field .type_ ,
335334 value_setter = type (self ).on_value_setter ,
336- editable = True if field .name != "id" else False ,
335+ editable = field .name != "id" ,
337336 )
338337 for field in self ._model_class .__fields__ .values ()
339338 ]
0 commit comments