streamlit-aggrid icon indicating copy to clipboard operation
streamlit-aggrid copied to clipboard

multiple jscode cellstyles

Open StefanBloemheuvel opened this issue 3 years ago • 0 comments

Hi,

First of all, thanks a lot for creating this package, it is amazing!

One question i have, is how i could apply multiple styles to the dataframe. For example, this is the code to format negative numbers red and positive numbers green:

cellsytle_jscode = JsCode(
    """
function(params) {
    if (params.value < 0) {
        return {
            'color': 'white',
            'backgroundColor': 'darkred'
        }
    } else {
        return {
            'color': 'white',
            'backgroundColor': 'green'
        }
    }
};


"""
)

I would like to add another style to this column, where I want to show a dollar sign before the numbers. Online I have found the following code:

function currencyFormatter(params) {
  return '£' + formatNumber(params.value);
}

How could I add that to streamlit-aggrid as well?

Thanks in advance!

StefanBloemheuvel avatar Jan 10 '22 16:01 StefanBloemheuvel