Subfile Context Menu Code Sample

Use this board to ask questions or have discussions with other Rich Displays users.
PatriceVincent
New User
Posts: 19
Joined: Fri Jan 09, 2015 5:21 am
First Name: Patrice
Last Name: Vincent
Company Name: Saphir Systèmes
Contact:

Subfile Context Menu Code Sample

Post by PatriceVincent »

Hi All,
I'm new to ProfoundUi, i would like to add a context menu to a subfile.
That way, i will copy the 2=Edit, 3=Copy, 4=Delete, 5=Show to a context menu.
So, when the user right click in a line, he can do these option with the mouse.
I dont have found an example of this in ProfoundUI examples, so if somebody has, it will help me.
I have read the posts but don't really understand how to create a widget...
Thanks !
Best regards,
Patrice
Scott Wagers

Re: Subfile Context Menu Code Sample

Post by Scott Wagers »

Hello Patrice,

I can give you a quick example on how to create a context menu.

First thing to do is add the menu to your record format containing the grid.
context1.png
context1.png (19.15 KiB) Viewed 1058 times
Set the 'context menu id' property of the Grid widget to the id of the added menu widget.
context3.png
context3.png (1.39 KiB) Viewed 1058 times
Set the choices/values you would like to make available to the user in the menu widget. (If no values are set, the values in the 'choices' property are used)
context2.png
context2.png (3.81 KiB) Viewed 1058 times
Hide the added context menu, by right-clicking the widget and selecting 'Hide'.
context6.png
context6.png (12.64 KiB) Viewed 1058 times
Now the menu should be available when the grid is right-clicked.
context4.png
context4.png (8.19 KiB) Viewed 1058 times
context5.png
context5.png (8.93 KiB) Viewed 1058 times
PatriceVincent
New User
Posts: 19
Joined: Fri Jan 09, 2015 5:21 am
First Name: Patrice
Last Name: Vincent
Company Name: Saphir Systèmes
Contact:

Re: Subfile Context Menu Code Sample

Post by PatriceVincent »

Hi Scott,
Nice !!! Thank you very much for this example.
I'm going to try it !
Best regards,
Patrice
User avatar
Glenn
Profound Logic Staff Member
Posts: 124
Joined: Mon Apr 14, 2014 4:08 pm
First Name: Glenn
Last Name: Hopwood
Company Name: Profound Logic Software
State / Province: Ohio
Country: United States
Contact:

Re: Subfile Context Menu Code Sample

Post by Glenn »

Patrice,

To expand on Scott's reply. There is some fairly simple JavaScript you can use to put the clicked context menu option into your onscreen (or hidden) option field and submit the screen.

First you would put some code in the 'onrowclick' property of your grid (Note the button to the right of the area where you enter text. You can click that to get a context sensitive text editor).
onrowclick.png
onrowclick.png (3.28 KiB) Viewed 1040 times
Here's the code:

Code: Select all

applyProperty("<ID property of your context menu>","user defined data",row);
This code puts the row that the user clicked into a property of the context menu named "user defined data" (note that you should change the text in the <> symbols to the id of your context menu).

You would then put some code in the 'onoptionclick' property of your context menu (Note that this image shows our text editor that is launched when you press the button mentioned above).
onoptionclick.png
onoptionclick.png (11.05 KiB) Viewed 1040 times
Here's the code:

Code: Select all

var rowClicked = this.pui.properties["user defined data"];
pui.set("<Name of option field in your grid>." + rowClicked, value);
pui.click();
This code pulls the row that the user clicked out of the property it was put in by the previous code and concatenates it with the field name of your option field. It then uses our pui.click() function to submit it back to the server.

If you are converting existing green screens, all of this can be done automatically by options available in our Conversion Themes (see this blog post http://www.profoundlogic.com/blog/dds-c ... ents-ibmi/).

Glenn
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Subfile Context Menu Code Sample

Post by Scott Klement »

This is a very nice explanation, guys. I wonder if we should put it in our documentation somewhere?
PatriceVincent
New User
Posts: 19
Joined: Fri Jan 09, 2015 5:21 am
First Name: Patrice
Last Name: Vincent
Company Name: Saphir Systèmes
Contact:

Re: Subfile Context Menu Code Sample

Post by PatriceVincent »

Hi Guys,
Thanks very much for your precious help.
i will try all and give you feedback.
Really nice !
Patrice
PatriceVincent
New User
Posts: 19
Joined: Fri Jan 09, 2015 5:21 am
First Name: Patrice
Last Name: Vincent
Company Name: Saphir Systèmes
Contact:

Re: Subfile Context Menu Code Sample

Post by PatriceVincent »

Hi Guys,

With your help, i succeed in creating a menu on a subfile.

To make it clear for others, the first part is to create a menu (Scott Wagers gave us screen copy of that).
At this stage, the menu is clicable but nothing is done when you select something.

To make the link beetween your subfile and this menu, you need to do what Glenn explain in the next part, the javascript code.
This code permit the system to put when you right click on the subfile the line number of your subfile (to know where to return information) in a variable, then call the menu and return your choice with the line number. This way, your otion (where normaly the user put 2, 3, 4 ... is completed).

I have a question to support team, i have tried to avoid javascript to only use the "menu response" zone of the menu. (Like a selectbox).
In that zone, i have put the same name as my subfile option :
ex :
Subfile Menu
ZCHOIX NAME ADRESS .... Menu response=ZCHOIX
ZCHOIX NAME ADRESS ....
ZCHOIX NAME ADRESS ....
ZCHOIX NAME ADRESS ....
With that, i have no error but my subfile is not impacted (i think because i haven't the raw number).
Is there a simple way to do that or are we obliged to use javascript ?

Thanks a lot for your help,
Patrice
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Subfile Context Menu Code Sample

Post by Scott Klement »

I think the "menu response" property is for when you use the menu as a "regular" menu. i.e., if you're writing a screen whose purpose is to be a menu where the user selects an option.

I don't think you can use "menu response" when a menu is used as a context menu of a subfile, for that you need to use the JavaScript technique that Glenn posted.
k2R400
Profound User
Posts: 62
Joined: Sat Feb 18, 2012 12:03 pm
First Name: Patrick
Last Name: THOMAS
Company Name: Oo2
Country: France
Contact:

Re: Subfile Context Menu Code Sample

Post by k2R400 »

And how to put an image behind the options like this ?

Image

Thank you
User avatar
Brian
Profound Logic Staff Member
Posts: 286
Joined: Thu Apr 14, 2011 10:23 am
First Name: Brian
Last Name: May
Company Name: Profound Logic Software
Contact:

Re: Subfile Context Menu Code Sample

Post by Brian »

You can embed HTML in the Choices property of the menu widget. So for example if I set my Choices property to the following:

<img src="/img/accept.png"> Option 1,Option 2,Option 3,Option 4,Option 5

It would look like this:
MenuWithImage.png
MenuWithImage.png (4.69 KiB) Viewed 868 times
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests