I’m attempting to pick up the identity of the record the user clicks on within a portal. To that end I’ve selected the field in the portal and attached a method to its onAction property.
However the method is not triggered. I’ve also tried the same thing with onFocusLost, onFocusGained, onDataChange. Similar non-reaction.
Am I misunderstanding the technique required to achieve my purpose?
Placed a transparent button on top of the portal field.
Placed a text table on top of the field.
Neither works. Also considered placing a rectangle shape, but these don’t accept actions.
Making the portal field editable doesn’t help. In this case it’s not appropriate to edit the text. I’m just attempting to pick up the user’s choice of record.
Scripting the user’s click in a portal is such common practice in FMP I’m puzzled at being thwarted at every turn in Servoy.
I have not tested this, but you should be able to create an form method for the form that has the portal in it. When createing the method, use the relationship controllers for that portal relationship.
You should then be able to attach that method a portal field using an event.
You can also create a tab panel that shows a form in list view that has a button next to each record. From what I have read, using list views in tab panels is not a good practice.
grahamg:
I’ve found that it’s necessary to add a Button to the portal line & set OnAction to the button. Portal data elements do not seem to support OnAction.
For info I then set a global and use that to display the required record
Delighted to hear your response because it made sense as a workaround. But it’s not working for me.
I can’t get a button to appear on each line of the portal. It turns up as a single object floating at the top of the portal. True, in early experiments I did briefly get a button to appear in multiple lines, deleted it and haven’t been able to restore the effect.
This is most frustrating. Asking a user to make a choice by clicking on a record in a portal is so very intuitive and dead simple to do in FMP. I’ve seen comments from Servoy staffers in the archives saying it works but I’m definitely having major difficulties.
I’ve also found this error if I dont select the portal element BEFORE adding the button. Selecting the portal points the object to be added to the portal.
BTW- I strongly agree with you that you should be able to click on a portal line to initiate a method. Hope this is implemented in the near future.
I used DFehrenbach’s hint (above). Selected the portal, added the button. The good news is I could now position the button anywhere I liked AND use the dataprovider property of the button to give it a field name. Works.
However, before I saw Graham and DFehrenbach’s postings I tried something else, which also works.
I tried a tabless tabPanel. However onAction wouldn’t trigger when a field was clicked. Then I remembered something Johan Campagner posted in February.
If you set something non editable in a table (portal or tableview) the component itself will never ‘be there’. Only used for rendering. So you don’t click on the field itself, so no action can be fired. (It never gets that far). You have to use a button for this at this time.
In my situation the field is a calculation and the form is a table. Added a button and gave it a dataprovider. Works.
Two methods for the same purpose and a better understanding of this corner of Servoy. Thanks for the help.