Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Callbacks to dynamically generated button

$
0
0

Hi All,
I am new to Dash and i am trying to make a kind of interactive dashboard for inventory management. There are several items which will be loaded from database


I want to have several small “Minus” buttons on each items like above to reduce the number when some one borrow, which i can do by a loop of this function

def makeitemcol(itemtype,item,quantity):

fonts = "2vw"

if (len(item) > 7 ) :

    fonts = "1.7vw"

imagestr = itemtype + "/" + item +".png"

col = dbc.Col([

                 dbc.Card([

                        html.Div([html.P(str(quantity))],style = CIRLE),

                        dbc.CardBody([

                        html.Div([html.P(item.capitalize())],style={"line-height": "1rem",'width': '90%', 'height': '100%','display': 'inline-flex','font-size': fonts,}),

                        # dbc.Button(html.I(className = "bi bi-plus-lg"),color="secondary", className="me-1",style=BUTP),  #{'width': '20%', 'display': 'inline-block'}),

                        dbc.Button(html.I(className = "fas fa-minus"),color="secondary", id="minusitem"+item, className="me-1",style=BUTM),   #{'width': '20%', 'display': 'inline-block'}),

                        dbc.CardImg(src=app.get_asset_url(imagestr), className = 'img',style={"display":"block","margin-left": "auto","margin-right": "auto",'width':'80%'}),

                                ]),

                            ],style={"border": "2px solid Gold","border-radius":"25px", "position": "relative"})

                ], width=2,)

return col

My problem now is how to match these button to callbacks. These buttons are dynamically generated so there is no fixed number of buttons and therefore callbacks will also need to generated dynamically.
Thanks in advance for any help.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles