Extra optional parameter for application.setValueListItems()

Discuss all feature requests you have for a new Servoy versions here. Make sure to be clear about what you want, provide an example and indicate how important the feature is for you

Extra optional parameter for application.setValueListItems()

Postby martinh » Thu Nov 13, 2008 6:30 pm

Hi,

Could it be possible to have an extra optional parameter for application.setValueListItems() that says if the valuelist must be sorted on displayvalue (boolean, default false)

So like this:

Syntax

application.setValueListItems(name,displayValArray/dataset,[realValuesArray],[autoconvert(false)], [sortOnDisplayValues(false)])

The reason for this request is, that I have a lot of displayvalues that are unstored calculations in my foundset, because the displayvalue must be shown in the correct language.
And sorting on unstored calculations in a foundset is not possible (if that was possible, then it would solve my problem also)
Now I create 2 arrays, one with ID-fields and one with DISPLAY-fields

Javascript can sort arrays, but the two arrays must remain in sync.

Code: Select all
_fs.loadAllRecords();
_fs.sort('description asc');  // Unfortunately this doesn't work because description is unstored calculation field

//Returns a foundset dataprovider (normally a column) as JavaScript array
var _id_array = databaseManager.getFoundSetDataProviderAsArray(_fs, 'country_id');
var _desc_array = databaseManager.getFoundSetDataProviderAsArray(_fs, 'description');

application.setValueListItems( 'countryname',  _desc_array, _id_array);


So it would be great if the application.setValueListItems() can have an option that it must be sorted on displayvalue (unless sorting on unstored calculations will be supported)

Or is there a simple way that this foundset can be converted to a dataset and that the sort can take place on the dataset?
But if that is easy, then the extra parameter will be easy as well I guess
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Extra optional parameter for application.setValueListItems()

Postby martinh » Thu Nov 13, 2008 6:50 pm

I created a work around, but the request would still be nice to have.

Code: Select all
_fs.loadAllRecords();
_fs.sort('description asc'); // Doesn't work because it is a unstored calculation

//   Create a dataset
var _ds = databaseManager.createEmptyDataSet( _fs.getSize(),  2)

for (var i = 1; i <= _fs.getSize(); i++)
{
   _fs.setSelectedIndex(i)
   
   _ds.setValue(i, 1, _fs.country_id)
   _ds.setValue(i, 2, _fs.description)
}

//   Now sort the dataset on column 2
_ds.sort(2, true)

//   Now fill the arrays with the sorted dataset
var _id_array = _ds.getColumnAsArray(1)
var _desc_array =  _ds.getColumnAsArray(2)

application.setValueListItems( 'countryname',  _desc_array, _id_array);
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium


Return to Discuss Feature Requests

Who is online

Users browsing this forum: No registered users and 5 guests