Been playing around witht he new M3 layouts and really liking the sidesheet for applying filters, but i’m struggling with dynamically adding content to it. For example, if I create a template and the side bar is empty then i can just drag a sidesheet content form into it for each page, that much is easy, but in the attached app, i cant work out how to add the sidesheet_template to the sidesheet when button_1 is clicked.
What I actually plan to do is create 2 buttons, I have a tabulator table in my app, and the sidesheet will have either filters that can be applied via button_1 and button_2 will show column visibility filters, via two different sidesheet content forms which i want to show in the sidesheet depending on the button clicked.
The only way I can find to do it so far is to add both the sidesheet content forms and toggle the visibility of them when each button is clicked, but there must be a way to add the sidesheet template via code that I am clearly not understanding.
Does anyone have any tips please?
Code Sample:
from anvil import *
from .sidesheet_template import sidesheet_template
class Form1(Form1Template):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run before the form opens.
def button_1_click(self, **event_args):
"""This method is called when the component is clicked."""
self.layout.show_sidesheet = not self.layout.show_sidesheet
#self.layout.add_component(sidesheet_template,[slot="sidesheet"])
Clone link: