Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Is there a way for the JsCode to call python code? #255

Open
mkleinbort-ic opened this issue Mar 16, 2024 · 4 comments
Open

Question: Is there a way for the JsCode to call python code? #255

mkleinbort-ic opened this issue Mar 16, 2024 · 4 comments
Labels
question Further information is requested

Comments

@mkleinbort-ic
Copy link

Conceptual question - mainly geared towards the master-detail feature in AgGrid.

Can the getDetailRowData parameter as seen here

"detailCellRendererParams": {
        "getDetailRowData": JsCode(
            """
                function (params) {
                    params.successCallback(params.data.detailForAgGrid);
                }"""
}

Call a function in python to return the json for display?

Currently I am wrapping the detail data as a json - but it's a lot of data to have loaded into memory all at once.

The ideal would be something like:

def get_relevant_data(params)->'json':
     ... 
     return detailForAgGrid

"getDetailRowData": JsCode(
     """
     function (params) {
         params.successCallback({get_relevant_data(params)});
    }"""
@PablocFonseca PablocFonseca added the question Further information is requested label Mar 21, 2024
@zeklan
Copy link

zeklan commented May 13, 2024

Have you managed to resolve this? I'm in need of a similar solution

@mkleinbort-ic
Copy link
Author

No; you can fake this for a while by nesting the data you need within the cell's value, but I've not figured out how to call python code from within the JS.

I imagine you could set up a FastAPI server to handle this - but I've not tried.

@zeklan
Copy link

zeklan commented May 13, 2024

I see, have you got an example of this method that I could refer to for implementation? would appreciate a lot since there aren't a lot of python x ag-grid on the web...

@zeklan
Copy link

zeklan commented May 13, 2024

nvm, I was able to figure the workaround out. Leaving snippet here for anyone else who ends up in this thread looking for the same sol'n:

GET_DETAIL_ROW_DATA = '''function (params) {params.successCallback(params.data.cities)}''' master_grid_options = {..., 'detailCellRendererParams' : { 'getDetailRowData' : GET_DETAIL_ROW_DATA }, ...} master_grid = Grid(grid_data=rowData, grid_options=master_grid_options)

where 'rowData' is the input data in the example code snippet of Dash's AG-Grid page https://dash.plotly.com/dash-ag-grid/enterprise-master-detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants