-
QuestionI'm fairly new to Flet, but really liking it. I have a datatable, and my table forms well. I'm trying to set a cell where the click event (on_tap) will call a function to define an action (right now, just trying to print the value from the first cell (cell 0) in the row. If I click on row 2 cell[3], how do I get the value of row 2 cell[0]? Here's what I have so far, got the
Any help is greatly appreciated. Code sampledef toggle_ssh(e):
selected_peer_ssh = row.cells[0].value
if selected_peer_ssh:
print(selected_peer_ssh)
else:
print("Didn't get the peer name for ssh toggle.") Error messageFile "/home/myuser/Developer/flet-test/main.py", line 52, in toggle_ssh
selected_peer_ssh = row.cells[0].value
^^^
NameError: name 'row' is not defined. Did you mean: 'pow'? ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Just to expand on this, I know I can click the datarow and get any cell value with an index for that cell, but only if I don't have an on_tap for the cell I click in. If you have the on_tap event on the cell it overrides the on_tap event for the row. In my case, each cell has a different action based on the on_tap event, and two of the cells depend on the value in the 0th position of the cell indexes. |
Beta Was this translation helpful? Give feedback.
-
I finally got this figured out. Given the format of a data table as follows:
Where
You can get the value from any cell on a row with the following (assuming you have an
Where Maybe this will help someone else down the road. |
Beta Was this translation helpful? Give feedback.
I finally got this figured out.
Given the format of a data table as follows:
Where
get_row_data
returns all the rows in the format: