What I’m trying to do:
I want to get the details of the datagrid row and display in on fields below.
What I’ve tried and what’s not working:
Getting the parent and set the values did not work
Code Sample:
class RowTemplate1(RowTemplate1Template):
...
def radio_button_1_clicked(self, **event_args):
"""This method is called when this radio button is selected"""
for r in self.parent.parent.parent.parent.get_components():
print ( "Parent " + str(type(r)))
#print ( "Parent " + str(type(r)))
if type(r) is Label:
lbl = type(r)
lbl.text = "stuff"
print("TEXET " +lbl.text)
1 Like
The general recommendation is to avoid stringing parent
attributes like that and instead use a pattern like this: Referencing parents/childern - #2
But going with your approach just for the sake of learning, after the if
statement, what you’d want to do next is just r.text = "stuff"
.
edit: Removed mistaken speculation corrected by @stucork below.
1 Like
Just a quick note that the if statement isn’t the problem and will work fine. It might also be worth using if isinstance(r, Label):
but in this example it’s the same result.
1 Like
The general recommendation is to avoid stringing parent
attributes like that and instead use a pattern like this:
Thanks for that, I was doing some testing trying to find the best way to do to that, however, the value of text I added is not showing on the UI at all, hence this question.
I was trying to do is when the radiobutton is selected, all the row detail will show at the Detail area below, from the image here, the DocumentId is empty when I expected “stuff” to show by assigning it to lbl.text
did you try @hugetim suggestion?
In your code you are doing
lbl = type(r)
lbl.text = "stuff"
But that can’t work because you are not changing the text of a Label
component but the type Label
The suggestion was to do
r.text = "stuff"
This way you are making a change on the component.
And if the suggestion hasn’t helped. A clone link would be useful so others can have a look at the app code.
1 Like