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)
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
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:
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.
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.
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
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)