Does anyone know how to configure comboboxes to show by default the first element of the value list associated with it?
Thanks in advance
var _record = foundset.getSelectedRecord() ;
var _formName = "win_" + _record.query_id ;
var _returnValues = forms[_formName].getExistingColumnsRealNames();
var _displayValues = forms[_formName].getExistingColumnFriendlyNames() ;
application.setValueListItems('blank',_displayValues,_returnValues) ;
//below is what you are looking to do:
_f_dataprovider = _returnValues[0] ;
var _ds = application.getValueListItems('filterChoices') ;
_f_filterChoices = _ds.getValue(1,2) ;
var _ds = application.getValueListItems('name') ; //returns 2 column dataset with (displayValues, returnValue) columns
foundset.dataprovider = _ds.getValue(1,2) ;
Per the wiki though: NOTE: this doesn't return a value for a valuelist that depends on a database relation or is a global method valuelist.
jd2p wrote:For example, many of our forms show a combobox that's populated from a valuelist based on table Currency. Now, we want all of those objects to show, by default the first element without the user having to select it.
- Code: Select all
var _ds = application.getValueListItems('name') ; //returns 2 column dataset with (displayValues, returnValue) columns
foundset.dataprovider = _ds.getValue(1,2) ;
Per the wiki though: NOTE: this doesn't return a value for a valuelist that depends on a database relation or is a global method valuelist.
scopes.globals.globalMethod(controller.getname())
_form = solutionModel.getForm(formName) ;
_fields = _form.getFields() ;
for ( var i in _fields ){
if (_fields[i].displayType == JSField.COMBOBOX ){
_dataprovider = _fields[i].dataProviderID ;
_valuelist = _fields[i].valuelist ;
_ds = application.getValueListItems( _valuelist.name ) ;
forms[formName][_dataprovider] = _ds.getValue(1,2) ;
}
}
andI don't want to store a a default value to the DB
I think are one and the same. (with two caveats that I can think of : 1. if combobox dataprovider is a variable 2. databaseManager.setAutoSave(autoSave) is false). By setting the combobox/valuelist to the first item, that value IS saved to the DB. So Juan's suggestion and mine do the same thing, but differ on how it is done.I just want the combobox to display the first element of the value list
var oForm = solutionModel.getForm(pFormName); // pformname contains the name of current form being displayed
var sFields = oForm.getFields();
var sDataProvider;
var sValuelist;
var dsLstName;
for ( var i in sFields ){
if (sFields[i].displayType == JSField.COMBOBOX ){
sDataProvider = sFields[i].dataProviderID ;
sValuelist = sFields[i].valuelist ;
dsLstName = application.getValueListItems(sValuelist.name ) ;
forms[pFormName][sDataProvider] = dsLstName.getValue(1,2) ;
}
}
Users browsing this forum: No registered users and 6 guests