Change a property a parent form when clicking a nested link

So this thread has been a huge help Thank you.
I have a simple question that I can’t figure out related to this though.
I have FormA that has a data table on it. I click a link in the data table and the column_panel_3 on FormA becomes visible - works great. Except when I want to pass through the school name from that data table I can’t get it working. (I want school_name.text on FormA to say the school name when the school_name_link is clicked) I tried Sender, parent, and a few things but I’m obviously making a mistake.

  def school_name_link_click(self, **event_args):
    #This works great
    get_open_form().page_panel.get_components()[0].column_panel_3.visible = True
    # This does not
    get_open_form().page_panel.get_components()[0].column_panel_3.school_name = self.school_name_link['school']

Any help would be greatly appreciated.

Welcome back!

I see two issues here.

First, is that you said you want to assign a new value to school_name.text, but your code seems to be assigning to school_name instead.

Second, I see a potential problem in how the code is trying to find the existing object named school_name. My clue is in comparing
column_panel_3.visible
to
column_panel_3.school_name
visible is a well-known member of all column panels. school_name is not. Most likely, school_name is a component in some other object. Perhaps it is a member of the form itself, just like page_panel is?

1 Like

Yea I think you are right. I did get it figured out after using some prints to see how it works. This is the code that works for me:

def school_name_link_click(self, **event_args):
get_open_form().page_panel.get_components()[0].column_panel_3.visible = True
print (get_open_form().page_panel.get_components()[0].get_components())
get_open_form().page_panel.get_components()[0].school_name.text = event_args[‘sender’].text

Glad it is working!

Also, unless I’m missing something you shouldn’t have to use .get_components()[0] if the components you are altering are on FormA, and were added using the IDE. That is, you should have direct access to the components without the need for indexing. For example,

def link_1_click(self, **event_args):
    """This method is called when the link is clicked"""
    get_open_form().school_name.text=self.link_1.text

This way, if your components ever change position the code will still work.


A couple other friendly tips when posting on the forum:

  • if there is an error, please share the error as we are able to help more easily
  • you can format your code nicely by wrapping it in backticks with the word “python”. For example:
```python

print('this will be syntax highlighted')

```
1 Like