Put query result into selectDialog valuelist

Having performed a query I want to put a column from the dataset into an array to use in a showSelectDialog valuelist. I have tried this:

var query = "select distinct x_header_text from contacts";

var maxRows = 100;
var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(), query, null, maxRows);
var myArray = new Array(dataset.getColumnAsArray(1));
var choice = plugins.dialogs.showSelectDialog('Select', 'Please select the client this task will apply to',myArray)

but even though the array seems to hold the values, it doesn’t work in the dialog. Where am I going wrong?

I had similar problems before, too. The problem lies in the kind of Array that is returned by dataset. It seems to be a Java Array and not a JS Array. What I do to overcome this is this:

var myOtherArray = new Array();

for ( var i = 0 ; i < dataset.getMaxRowIndex() ; i++ )
{
myOtherArray = dataset.getValue(i, 1);
}
var choice = plugins.dialogs.showSelectDialog(‘Select’, ‘Please select the client this task will apply to’,myOtherArray) [/quote]
That should work.
But then one remark to the Servoyans:
SelectDialog used to return a list instead of a popup if there were many values. Now, a list is also returned but the dialog window is not resized. The list consists only of 1 line. Can this be fixed?
Thanks
Patrick

you are putting an array inside an array

this works fine

var query = “select distinct x_header_text from contacts”;

var maxRows = 100;
var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(), query, null, maxRows);
var myArray = dataset.getColumnAsArray(1);
var choice = plugins.dialogs.showSelectDialog(‘Select’, ‘Please select the client this task will apply to’,myArray)

I missed the double array issue in new Array(dataset.getColumnAsArray(1)). That looks wrong, indeed.

But I remember having a problem with arrays (see java script question on arrays - Classic Servoy - Servoy Community). There you said

if you have a real javascript array then splice works like it should, but with a javaarray (the thing you get back from getColumnAsArrya(2)) it behavious a bit different… (it doesn’t shrink)

I am always a little unsure of what kind of array I am having, that’s why I bulid my own arrays most of the time. Could you explain in which circumstances there is a difference?

Thanks
Patrick

that is when you are using javascript methods on arrays (like splice).
some behave a bit different. I think i have fixed splice to do the same as a javascript array.

In the above example it doesn’t do anything javascript specific, only a giving a javacall a return value of a java call. That should always work fine.

Thank you! Did you see my little remark on SelectDialog? I think that behaviour was better before. My observation comes from 2.1b4 and it looks like this:

Thanks for all the responses guys - problem solved!

i have no idea what that happens
I i run the above example i see a much larger sized dialog
And besides that the dialog we are showing is a internal java dialog. We are not setting any sizes

What happens if you resize the dialog and then close and reopen it?

strange, what you describe… The dialog cannot be resized; there is no handle for that.

hmm

what os/java version are you using?
Did you change one of those?

no. I have always been on Win XP, Java version 1.4.2_03-b02. I have never changed that since I work with Servoy…