Page 1 of 1

Extra optional parameter for application.setValueListItems()

PostPosted: Thu Nov 13, 2008 6:30 pm
by martinh

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:


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.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

Re: Extra optional parameter for application.setValueListItems()

PostPosted: Thu Nov 13, 2008 6:50 pm
by martinh
I created a work around, but the request would still be nice to have.

Code: Select all
_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++)
   _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);