Hello guyz, im developing dashboard terminal for my company.
I’ve faced issue about callbacks.
Situation is my datapicker component keep triggering event it dont have any output callback.
Let me share :
Here is how i created layout :
layout_12 = .... dbc.Row([dcc.DatePickerSingle(id='date-picker2', className="dash-date-picker",
date = date.today(),
persistence = True,
persistence_type = 'memory'
), .....
layout = html.Div([
dcc.Store(id='oeelist0',data=prdconf(((date.today() - timedelta(days=1)).isoformat(),date.today().isoformat(),"day"))[0]),
dcc.Store(id='oeelist1',data=prdconf(((date.today() - timedelta(days=1)).isoformat(),date.today().isoformat(),"day"))[1]),
dcc.Store(id='oeelist2',data=prdconf(((date.today() - timedelta(days=1)).isoformat(),date.today().isoformat(),"day"))[2]),
dcc.Store(id='oeelist6',data=prdconf(((date.today() - timedelta(days=1)).isoformat(),date.today().isoformat(),"day"))[6]),
dcc.Store(id='device-info-store'),
html.Div(id='main-layout-div')
])
@app.callback(
Output('main-layout-div', 'children'),
Input('device-info-store', 'data')
)
def set_layout(device_info):
if not device_info:
raise exceptions.PreventUpdate
print(device_info)
device_type = device_info.get('device_type', 'Desktop')
device_type = "12inchDevice"
if device_type == "12inchDevice": # Replace "12inchDevice" with the actual identifier for the device
return layout_12
else:
return layout_27
and here is the only callback that use DatePicker as Input :
@app.callback(
[Output('work-dates', 'data'),
Output('refresh3', 'children'),
Output(component_id='oeelist0', component_property='data'),
Output(component_id='oeelist1', component_property='data'),
Output(component_id='oeelist2', component_property='data'),
Output(component_id='oeelist6', component_property='data'),],
[Input('btn-day2', 'n_clicks'),
Input('date-picker2', 'date'),
Input('btn-week2', 'n_clicks'),
Input('btn-month2', 'n_clicks'),
Input('btn-year2', 'n_clicks')]
)
def update_work_dates(n1, date_picker, n2, n3, n4):
stored_date = date_picker
print(f"**{date_picker}**")
print("burasııı")
print(callback_context.triggered[0]['prop_id'])
if n1 or date_picker or n2 or n3 or n4:
data = update_date('2', date_picker, callback_context)
print(f"params= {data}")
if data != {}:
oeelist = prdconf(params=(data["workstart"], data["workend"], data["interval"]))
(oeelist[0],oeelist[1],oeelist[2],oeelist[6],)
a = update_date_output( n1, date_picker, n2, n3, n4, data)
print("****************************************************************")
return a + (oeelist[0],oeelist[1],oeelist[2],oeelist[6],)
else:
return no_update
else:
return no_update
You can reach full code of subpage Here
Ty.