Yes I am trying to use the table number formatting way and I tried two things.
One was changing the style_data_conditional:
data = df.to_dict('records'),editable=False,filter_action="native",sort_action="native",selected_rows = [], sort_mode="multi",page_current= 0,page_size=20,page_action="native",
style_cell_conditional=[
{
'if': {'column_id': c},
'textAlign': 'center'
} for c in ['processDate', 'symbol', 'imbSide', 'mktOrderImbSide']
],
style_data={
'color': 'black',
'backgroundColor': 'white'
},
style_data_conditional=[
{
'if': {'row_index': 'odd'},
'backgroundColor': 'rgb(220, 220, 220)',
},
{
'if': {'filter_query': '{imbSide} = BUY',
'column_id' : 'imbSide'
},
'color': 'rgb(0, 128, 0)'
},
{
'if': {'filter_query': '{mktOrderImbSide} = BUY',
'column_id' : 'mktOrderImbSide'
},
'color': 'rgb(0, 128, 0)'
},
{
'if': {'filter_query': '{imbSide} = SEL',
'column_id' : 'imbSide'
},
'color': 'red'
},
{
'if': {'filter_query': '{mktOrderImbSide} = SEL',
'column_id' : 'mktOrderImbSide'
},
'color': 'red'
},
{
'if': {'column_type': 'numeric'
},
'backgroundColor': 'blue'
},
],
style_header={
'backgroundColor': 'rgb(0, 128, 0)',
'color': 'white',
'fontWeight': 'bold'
})
to include a query for column type : numeric. But it doesn’t show up as blue. Maybe because the title of each column is text? I don’t know why.
Second thing I tried was to change the format where I define the ‘columns’ in the dash table:
tableoutput = dash_table.DataTable(id='dataframe',
columns=[[{'id': c, 'name': c, 'format' : Format()} for c in df.columns],
[{'id': c, 'name': c, 'type':'numeric', 'format' : Format().group(True)} for c in ['imbNotional']]
],
data=df.to_dict('records'),editable=False,filter_action="native",sort_action="native",selected_rows = [], sort_mode="multi",page_current= 0,page_size=20,page_action="native",
This method doesnt even output a table.
I thought the first method will work since if it did I could just format all columns with numbers to have comma separator.