Data table convert it to label text

Hello, hope all are fine!
im trying to figure out a challange, i to use data from datagrid to label.text im using this function:
def label_1_show(self, **event_args):
n=[r[‘TIME’] for r in (app_tables.table_0.search())]
#print(n)

self.label_1.text=n

the datatable is like this:
Capture16

I need to pass each row 1,2 in oreder of add on dataset, show like label.text()

the result that i have now is:
[1,2]
[1,2]

but i nee to see:
1
2
excatly like the datatable

Any help ca be great, thank you!

    col1=''; col2=''
    for row in app_tables.table_0.search():
      col1+=row['time'] + '\n'
      col2+=row['try'] + '\n'
    self.label_1.text=col1
    self.label_2.text=col2

Hello thanks tofor replay it help a lot, im trying to put this logic on datagrid and return me like this:

How we can inject the results:

    self.label_1.text=col1
    self.label_2.text=col2

Properly on the datagrid elements, thank you!

I try other test now i can put on datagrid but problem is that is print for number of items for example Time columns [1 to 6] give 6 same blocks

Code that i use on Row_Template:

Blockquote
from ._anvil_designer import RowTemplate1Template
from anvil import *
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables

class RowTemplate1(RowTemplate1Template):
def init(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
col1=‘’; col2=‘’
for row in app_tables.table_0.search():
col1+=row[‘time’] + ‘\n’
col2+=row[‘try’] + ‘\n’
self.label_1.text=col1
self.label_2.text=col2

# Any code you write here will run when the form opens.

And on Form1:
from ._anvil_designer import Form1Template
from anvil import *
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables

class Form1(Form1Template):

def init(self, **properties):
self.init_components(**properties)
col1=‘’; col2=‘’
for row in app_tables.table_0.search():
col1+=row[‘time’] + ‘\n’
col2+=row[‘try’] + ‘\n’
self.label_1.text=col1
self.label_2.text=col2

self.repeating_panel_1.items=app_tables.table_0.search()

How i can fix it please

You don’t need to do all that for the Grid widget. Just select ‘Add Columns From Data Table’ in the grid properties (click ‘Remove Column’ for each of the default columns), and put this line in your init method:

self.repeating_panel_1.items=app_tables.table_0.search()

If you want to add your own custom widgets to the repeating panel in the grid, just be sure to bind them to a designated row of your data table:

Note that if you add widgets that allow you to edit values (such as text fields), and select the ‘write back’ option, changes made in the user interface will be saved back to the data table.

https://anvil.works/build#clone:QANY2QZKP46MTZV7=IFYRYJS7VMFAKGRS4IGJUQYP

1 Like

Also note that it may be appropriate to use number and true/false columns in your data table. In the example app linked above, I added another grid which demonstrates how to use checkboxes to display/edit the true/false values, and text boxes which are constrained to number values.

Hello, thank for replay, i see the app of explication but i can’t figure out how fo list the data of labels on datagrid



Label are o datagrid, but the datagrid are seem not considering the labels, for example for count the max row in table i think something wrong, when i call the label

The propriety of repeating_panel_1
as taken from here:

In that last screen shot, you haven’t added the data binding

Bindings get added to each label in the repeating panel, so they are individually bound to a column in the table (see the previous screen shot I posted above)

Thank you so much for your time, i fix the proble following your istructions. Thank you!