There is a Multiselect Listbox on form called “table_list”. While using “Debug Smart Client” I was able to use this function to get selected values:
elements.table_list.getSelectedElements()
However when I use Web Client - it doesn’t work, simply returns blank.
In manuals I was able to find a full notation using form path like so:
forms.table_maker.elements.table_list.getSelectedElements()
When I use it word “elements” gets underlined with warning: “The property elements is private”
How can I access form elements from both smart client and web client? I am new to Servoy.
Please help,
thank you.
Would someone please answer this question? I’m very curious to know. The manual seems straight forward on using complete path to form elements like so:
forms.table_maker.elements.table_list.getSelectedElements()
But there is the “The property elements is private” warning in my Servoy set up. What am I overlooking?
Have a look at the encapsulation properties of the form, the elements are probably hidden. Which results in this warning.
Hi ,
Its seems to be bug.
I have tried to reproduce it.
Placed a multiselect list box inside a tab and tried to get the values from the parent form. In case of smart client it return me an array of selected values but in case of web client it just returned a blank array. I make sure that the encapsulation is turned off.
I have also attached a solution with with this post. Sheinin, Please verify if you get the same problem.
Thanks,
Sovan
multiSelectListBoxBug.servoy (4.47 KB)
Yes, I made sure Encapsulation has “Hide Elements” unchecked and still seeing the error.
Really a BUG? ![Shocked :shock:]()
try to force-rebuild: choose menu ‘Project > Clean’
mboegem:
try to force-rebuild: choose menu ‘Project > Clean’
The error message changed to:
"The property table_maker from the instance forms is private"
Before clean it used to say
"The property elements is private"
Any ideas?
sergei.sheinin:
Any ideas?
Yes, you have ‘hide in scripting’ checked at the encapsulation properties.
Untick this option, rebuild again and the message should be gone.
However, reading your first post we’re a bit off topic here.
the initial question was why you couldn’t get the values from your listbox in web client.
I really don’t see how using the full reference: forms.table_maker.elements etc.
would make a difference to elements.table_list_getSelectedElements()
If it doesn’t work, just attach a dataprovider to the listbox and read that value.
If you find it uncomfortable having the values as a CR separated list, use this:
foundset.<MyDataprovider>.split('\n')
Hope this helps
Very interesting suggestion about data provider. I have these lines of code in the form’s js:
var test = "console.log('"+elements.table_list.getSelectedElements()+"')"
plugins.WebClientUtils.executeClientSideJS(test)
which produced blank output. As soon as I attached data provider - a global variable that is never used - the above lines of code started working.
Why does attaching a data provider that is never used in the project’s code have such affect on “elements.table_list.getSelectedElements()”? Could it indeed be a bug as was suggested earlier in the thread?
sergei.sheinin:
Why does attaching a data provider that is never used in the project’s code have such affect on “elements.table_list.getSelectedElements()”? Could it indeed be a bug as was suggested earlier in the thread?
I don’t know how Servoy deals with the listbox in the background, so I can’t answer that question.
What interests me though is why you didn’t have a dataprovider attached to the listbox?
I mean: a dataprovider is where your values end up in the first place and it’s easier to grab those values.
If the dataprovider is a column in a table you will have the values directly in your database without a single line of code…
mboegem:
What interests me though is why you didn’t have a dataprovider attached to the listbox?
I mean: a dataprovider is where your values end up in the first place and it’s easier to grab those values.
If the dataprovider is a column in a table you will have the values directly in your database without a single line of code…
I use “valuelist” property of listbox equal “tableListValues” with the following .js code:
var qry = "SELECT DISTINCT table_name FROM dictionary"
var dataset = databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(controller.getDataSource()), qry, null, 100)
application.setValueListItems('tableListValues', dataset)
[/quote]
I must be "SELECT DISTINCT..." from a DB table in this case.