justpy-org / justpy

An object oriented high-level Python Web Framework that requires no frontend programming
https://justpy.io
Apache License 2.0
1.22k stars 96 forks source link

how to add a `valueFormatter` on the `AgGrid` component ? #256

Closed pabloazurduy closed 1 year ago

pabloazurduy commented 3 years ago

Hi, I was reading the AgGrid documentation About Value formaters

Is there a way to use that formater/define it inside justpy ? This is my example:

import justpy as jp
grid_options = {
    #'rowHeight': 40,
    'columnDefs': [
      {'headerName': "Make", 'field': "make"},
      {'headerName': "Model", 'field': "model"},
      {'headerName': "Price", 
       'field': "price",
       'cellStyle': {'--tw-border-opacity': 1,
                     'border-color': 'rgba(96, 165, 250, var(--tw-border-opacity))',
                     'border-width': '2px',
                     'border-radius': '0.25rem',
        #'valueFormatter': how to add it ?
        }
      },
    ],
    'rowData': [
      {'make': "Toyota", 'model': "Celica", 'price': '0.25' },
      {'make': "Ford", 'model': "Mondeo", 'price': '0.24234324234235234' }
    ],
}

def grid_test():
    wp = jp.WebPage(tailwind=True)
    grid = jp.AgGrid(a=wp, options=grid_options, theme='ag-theme-material')
    grid.html_columns = [2]

    for col_def in grid.options.columnDefs:
        col_def.editable = True
        #col_def.cellStyle = ['rounded','border-2','border-red-500']
    return wp

app = jp.app
jp.justpy(grid_test, start_server=False)

Thanks in advance !

othalan commented 3 years ago

This seems similar to the issue #261. Will this also be fixed in the next version?

elimintz commented 3 years ago

Good catch. I will make this change.

WolfgangFahl commented 2 years ago

@elimintz has this been done or should be in one of the upcoming milestones?

WolfgangFahl commented 1 year ago

see #685