Sorting Array

I am doing a getDataSetByQuery placing the results (a list of numbers) into an array, and then sorting the array as follows:

var queryStatement = "SELECT sgb_branch_nbr FROM sgb_branch";
var query = queryStatement;
var maxReturnedRows = 200;
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(),query,null,maxReturnedRows);
var branch_numbers = dataset.getColumnAsArray(1);
branch_numbers.sort();
application.setValueListItems( "sgbContactAccess", branch_numbers );   
controller.loadAllRecords();
}

The results are sorted, but the numbers are appearing as follows:
121.0
168.0
181.0
201.0

Does anyone know how to remove the ‘.0’

Thanks for any help

have you tried parseInt?

No, I haven’t. How/where should I use it. Sorry, I am a bit of a newbie where Java is concerned.

what datatype does the column sgb_branch_nbr have? Is it an integer or a number?

It’s an integer.

could you try this:

var branch_numbers_int = new Array();
for ( var i = 0 ; i < branch_numbers.length ; i++ )
{
branch_numbers_int = parseInt(branch_numbers*)
_
}*_
and then work with branch_numbers_int?

I have tried this:

var queryStatement = "SELECT sgb_branch_nbr FROM sgb_branch";
var query = queryStatement;
var maxReturnedRows = 200;
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(),query,null,maxReturnedRows);
var branch_numbers = dataset.getColumnAsArray(1);
var branch_numbers_int = new Array();
for (var i = 0; i < branch_numbers.length ; i++)
{
branch_numbers_int[i] = parseInt(branch_numbers[i])
}
branch_numbers_int.sort()
application.setValueListItems( "sgbContactAccess", branch_numbers_int);   
}

and I get:
102.0
103.0
121.0
etc.
I have tried this:

var queryStatement = "SELECT sgb_branch_nbr FROM sgb_branch";
var query = queryStatement;
var maxReturnedRows = 200;
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(),query,null,maxReturnedRows);
var branch_numbers = dataset.getColumnAsArray(1);
branch_numbers.sort()
var branch_numbers_int = new Array();
for (var i = 0; i < branch_numbers.length ; i++)
{
branch_numbers_int[i] = parseInt(branch_numbers[i])
}
application.setValueListItems( "sgbContactAccess", branch_numbers_int);   
}

and I get the same result.
I have also tried it without the sort:

var queryStatement = "SELECT sgb_branch_nbr FROM sgb_branch";
var query = queryStatement;
var maxReturnedRows = 200;
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(),query,null,maxReturnedRows);
var branch_numbers = dataset.getColumnAsArray(1);
var branch_numbers_int = new Array();
for (var i = 0; i < branch_numbers.length ; i++)
{
branch_numbers_int[i] = parseInt(branch_numbers[i])
}
application.setValueListItems( "sgbContactAccess", branch_numbers_int);   
}

and surprisingly, I still get the same result.
Am I doing something wrong here?[/quote]

I have never played with “numbered” value lists…

Your value list has to be attached to some field. How is the number formatting of that field?

The valuelist is attached to the field sgb_branch_nbr (this is in a portal) and the field property is 0000

ok. forget my tips regarding parseInt. I have made a test solution and came up with the same results as you.

So the question has to be passed on to the Servoyans, since they build the value lists. I am also getting 281.0 and so on.

check out:

you can use utils.numberFormat(Object number, Object fractions)
inside the utils node of the editor.

I am starting to add listings to my solution that are the result of a query. I want to be able to add a button for each record that I can attach to method to that would display a related form.

Is there any documentation regarding this issue. From everything I have read, this would be the best way to display large listings. I can run the query but I am unsure the the best way to display the result set to include a button.

Thanks,
Erich

If you place a button (or image) alongside the field(s) in the row on the form, the button will be displayed for each record. You can then attach a method to the button (or image).
Note: If your list is diplayed in a portal, you will need to select the portal before inserting a button or image to the form. If not, then the button will not be displayed for each record.

how do I map the query results into the fileds in the listing?

Thanks for the help.

var queryStatement = "SELECT......
var query = queryStatement;
var maxReturnedRows = 200;
var dataset = databaseManager.getDataSetByQuery(forms.myForm.controller.getServerName(),query,null,maxReturnedRows);
var myVar = dataset.getcolumnAsArray(1);

Add extra myVar and increment (1) for each filed you are selecting.

Excellent, thanks for your time.