What I’m trying to do:
I want to assign a tuple of dicts to a repeating panel inside a data grid. 1. Assignment of 3 columns incl. Title and Data Key to a data grid:
dict_columns = [
{ "id": "A", "title": "Application code", "data_key": "application_code"},
{ "id": "B", "title": "Short Name", "data_key": "name_short"},
{ "id": "C", "title": "Long Name", "data_key": "name_long"}
]
self.data_grid.columns = dict_columns # set columns to the data grid
Creation of header components.
Assignment of the data to the repeating panel & setting text to alignment=‘center’
Point 1 and 2 is working perfect, but point 3 data is not showing.
In the docs I even found the same example but it’s not showing.
Code Sample: Part responsible for the data assignment
So there is no way to do it with the basic anvil data grid component? Populating the grid with a database was never a problem, but using code and dict’s to populate is harder than I thought.
Dicts and database rows behave in the same way. There is no difference in how a DataGrid is used with database rows or lists of dictionaries.
That custom component uses the DataGrid. You can clone it and see how it works. Understanding how it works is not going to be easy for a beginner, please ask more specific questions if you don’t.
I want to assign my dict to the repeating panel of my data grid(That panel already exist). I’m getting no errors and the repeating panel of data grid stays empty. Why it’s not working?
With DataGrid.add_component(RepeatingPanel(item=list_dict_rows) I was able add a new Repeating panel with data displayed, but I am not able to fill the existing one in data grid. I’ve missed there something.
I’ve checked your Custom Componen and understand almost everything in it. I want just to find out what I’ve missed, that the data is now showing in the repeating panel.
I could solve it probably by adding Label components for each row, similar approach like the headers rows.
Ok. Now I understand. I will try to implement it with the custom component from Stefano. I need that flexible way for my Grid. Thank you both for the patience with my questions🙂