21
Views
7
Comments
[GTree] How to add an action to a NodeName to GTree
gtree
Reactive icon
Forge asset by Pedro Neto
Application Type
Reactive

W drzewie Gtree wyświetlam listę pracowników. Chciałbym otworzyć okno z danymi tego pracownika po kliknięciu na nie, jak mogę dodać taką akcję do GTree?

2022-12-22 10-00-39
Beatriz Sabino

Hi Piotr,

For a more accurate response, I suggest asking your question in English next time so that more people can assist you. I've used the AI translation feature to translate your question, so I hope I’ve understood your request correctly.

If you're looking to redirect a user to another screen when clicking on a node name, I’ve attached an .oml file with a potential solution.

This component utilizes a node list (structure) to create your list. The structure has an attribute called RelativeLinkURL, which you can use to create a link when clicking on a node name. In my example, I used the Users entity to create the list. I created a data action to fetch the records, and in the OnAfterFetch event, I looped through the records and appended them to the node list, setting the appropriate properties (yours might differ). 

In the RelativeLinkURL attribute, I created a link to another page, specifically the UserDetails page, where the user's information will be displayed. If you don’t yet have a similar screen in your application, you’ll need to create it.

The component also includes an OnClickNodeLink event, which you can use to redirect the user to the URL specified in the RelativeLinkURL attribute. In the event handler logic, simply add an external site node with an input and assign it the RelativeLinkURL.

Hope this helps!


GTree_Example.oml
UserImage.jpg
Piotr Nowicki

Sorry for the question not in English, and thank you very much for your answer. This is very helpful, but instead of redirecting to another site, I just want to click on a name in the tree and assign its id to the variable and display all the information about this member in the window below the tree. Is there such a possibility? 

2022-12-22 10-00-39
Beatriz Sabino

Hi Piotr,

Yes, that’s possible.

I’ve added a new screen called UsersListWithDetail. In this screen, I’ve created a local variable called SelectedUser to display their information when you click on a user’s name.

I’ve also updated the append mapping in the OnAfterFetch event so that the RelativeLinkURL now uses just the UserId

Additionally, I modified the OnClickNodeLink event handler to filter the selected user and display their details below the list. 

I’ve used a form for this, but feel free to use any widget or layout that fits your needs. 

Below is the updated .oml file.

I hope this helps!

GTree_Example_Updated.oml
UserImage.jpg
Piotr Nowicki

Hi, thank you for your reply. Unfortunately, after implementing your solution, I get something like this on the screen. All the time trying to redirect me to a website that doesn't exist. How to exclude it? 

2022-12-22 10-00-39
Beatriz Sabino

Hi Piotr, 

Could you share your .oml file so I can better understand what might be happening? Or at least a screenshot of the logic you are using to define the RelativeLinkURL and the logic in the OnClickNodeLink event handler. 

Thank you.

UserImage.jpg
Piotr Nowicki


2022-12-22 10-00-39
Beatriz Sabino

Your logic seems pretty much the same as what I have in the .oml file I shared. So, without seeing your .oml, I can't fully understand what's going wrong.

Have you tried refreshing all the dependencies?

Also, are you using the correct GTreeOnclickNodeLink action?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.