a quick note that using append alone isn’t enough here.
Use either:
self.repeating_panel.items.append({'foo':'baz','message':'Error!'})
self.repeating_panel.items = self.repeating_panel.items
or
self.repeating_panel.items = self.repeating_panel.items + [{'foo':'baz','message':'Error!'}]
related topics:
This is exactly the right way to do it. In fact, I would probably create one or more named dummy objects so that I can easily refer to them later. Something like this, perhaps:
def __init__(self, **properties):
self.init_components(**properties)
# When the form is created, populate the RepeatingPanel
self.data = [ ...your actual data... ]
self.new_item = {"foo": "", "bar": ""}
self.repeating_panel_1.items = self.data + [self.new_item]
def save_new_item_click (se…
The great thing about repeating panels:
set the items with a list of length n --> n item_templates appear with the item property set
The not so great thing about repeating panels:
If the list is long or the item_template has many data_bindings the form can take a long time to load
If the list changes, say by deleting an item or adding an item, then it can be a UI nightmare to have to repopulate the item_templates of a repeating_panel
deleting an item works well:
You don’t need…
regarding how to loop over the repeating panels - you have some optoins
for componet in repeating_panel.get_components():
# do something
or use the __init__
method of the ItemTemplate itself
class ItemTemplate(ItemTemplateForm):
def __init__(self, **properties):
self.init_components(**properties)
# now you have self.item
if self.item['bar']:
# do something...
self.bar_component.visible = False
or set databindings on the components of ItemTemplate
you might also find this post helpful
Hello and welcome,
You may find the documentation on DataGrids helpful.
If you want TextBox components inside the DataRowPanel so that the columns are consistent with the DataGrid, you could try this approach.
grid=DataGrid()
self.add_component(grid)
# create some columns
grid.columns = [
{ "id": "A", "title": "Name", "data_key": "name" },
{ "id": "B", "title": "Address", "data_key": "address" },
{ "id": "C", "title": "Age", "data_key": "age" }
]
# create some rows of data
items = [
{…