Page 1 of 1

Loading Accordion Widget from SQL Data

Posted: Thu Nov 14, 2019 5:22 pm
by Bernie
Hello, How can I load the Accordion Widget from a SQL statement? I want to load a listing of the applications available based on what the user is authorized to.

Re: Loading Accordion Widget from SQL Data

Posted: Fri Nov 15, 2019 1:25 pm
by matt.denninghoff
The Accordion Layout is not designed to show any data itself, other than the section names. Section names can be "bound" to a field. Read here for binding in Designer: https://docs.profoundlogic.com/display/ ... ing+Dialog

So, if you use an SQL statement to populate a variable in your program with comma-separated values, you can assign that value to the bound field. Then when you call pjs.display(), Profound.js will use the assigned value:
https://docs.profoundlogic.com/pages/vi ... d=31752762

Re: Loading Accordion Widget from SQL Data

Posted: Fri Nov 15, 2019 3:21 pm
by Bernie
So I can't set the section names at the time the screen is being loaded? I tried to assign names to the sections and then set them in the javascript but nothing happens. What other widget would be good for this if the Accordion can't be modified while displaying it?

Re: Loading Accordion Widget from SQL Data

Posted: Sun Nov 17, 2019 11:21 pm
by Scott Klement
You want to load a list of applications that the user is authorized to and make them section names? Sorry, that doesn't make any sense to me...

Re: Loading Accordion Widget from SQL Data

Posted: Mon Nov 18, 2019 9:06 am
by Bernie
I need to provide some method for the users to view all of their apps available and then get to each one of them, similar to a menu system on the IBM i.

Re: Loading Accordion Widget from SQL Data

Posted: Mon Nov 18, 2019 10:17 am
by matt.denninghoff
It is certainly possible to setup the section names for the screen and then display the screen along with those section names. Like Scott indicated, there are better widgets for doing what you described--menu widget or select box. The data in those widgets can be populated with SQL statements without needing to code the SQL in the application and binding first.

You said, "So I can't set the section names at the time the screen is being loaded?" It is possible to set section names immediately before displaying the screen (via pjs.display) by setting a bound field. It is not possible to set the section names after the screen has loaded. Are you saying you're trying to set them with JavaScript in the Designer or via your Profound.js (Node.js) application?

Perhaps if you showed what code and display file you tried it would help.

Re: Loading Accordion Widget from SQL Data

Posted: Mon Nov 18, 2019 10:23 am
by Bernie
Okay, so I would be better of to use the menu widget to provide what I'm looking for? Do you have a sample of loading this from SQL?

What I was trying to do with the Accordion widget was create an expandable menu where I could setup the sections based on what the users were authorized to and then what was available in each section would be the applications or the subsets of applications that is available to the user. I don't have much for a screen or code because I was at the beginning trying to set up the widget to get it to work. And I was trying to set this within node.js because it would be where the SQL would be executed upon initial load up of the main menu application.

Re: Loading Accordion Widget from SQL Data

Posted: Tue Nov 19, 2019 6:15 pm
by matt.denninghoff
You cannot use the Accordion Layout widget for what you're describing. The menu is closer to what you want. I would use SQL in the Profound.js application to create a comma-separated list of program names. See here for PJS query:
https://docs.profoundlogic.com/pages/vi ... d=37028376

You might need to reference this for how to pass the variable to the display:
https://docs.profoundlogic.com/pages/vi ... d=31753041

Binding the "menu response" property causes the menu to send data back to your Profound.js application when the user clicks on an option. You can search for "bind" or "binding" in our documentation for more information on binding, or read starting here:
https://docs.profoundlogic.com/display/ ... Properties