I am updating a single card using a callback routine ;
I have around 10 elements to update.
As per my practice, I can write a routine that will pass these 10 elements to update.
But,
Is it possible in the dash to update all the elements of the card by passing a dictionary? ( i.e in a group )
It doesnt look like it would be possible since it isnt props, however, you could create a function where you pass a dictionary and it responds back with a fully created card.
card_description is the dictionary that contains the company name.
How will I feed values in my_card ids? Also please suggest how an I change the style color of the card base on value (green for +1 and red for -1 ) in one of dictionary element.
Here is an small example, you can expand the dictionary to include whatever properties you want to feed.
def buildCard(cd):
if cd['color'] == '+1':
color = 'green'
elif cd['color'] == '-1':
color = 'red'
else:
color = 'black'
myCardDetails = #the predefined format you want for the card from the dictionary, ie. values, colors, other styles.
myCard = dbc.Card(id=cd['id'], children=myCardDetails)
return myCard
myCards = [{'id':'card1', 'description':'this is a test'},{'id':'card2'},{'id':'card3'}]
layout = []
for cd in myCards:
layout.append(myCard(cd))
You can use this to dynamically update a single id or redo all the cards in a single callback depending on what triggered the changes.