Hi
I have had a little problem when I was exporting data with the framework function “svy_nav_base.getExportFormFields”. The Problem occures when there is a Button on the form (or other things without an DataProviderID) and after the Button there is for example a text field with a date. In the Form I have formatted the date with “dd.MM.yyyy” and that works. As I figured out, the problem is that in this special case, the “_colNames”-array will be filled with different index than the “_format”-array. So, for test purposes, I have changed the code as shown below (the original code is commented). With this change, it works perfect for me.
Best regards, Roland
function getExportFormFields(_form) {
//pass in the form name
var _elements = forms[_form].elements.allnames;
var _colNames = new Array();
var _vlNames = new Array();
var _formats = new Array();
var _jsTable, _JSColumn, _relation;
var _colPos = -1;
/** @type {String} */
var _datap
if (/_tbl/.test(_form) && _elements.length > 0) {
_elements.sort(function(a, b) {
return forms[_form].elements[a].getLocationX() - forms[_form].elements[b].getLocationX()
});
}
var _type
for (var i = 0; i < _elements.length; i++) {
// only export field not buttons.
_type = forms[_form].elements[_elements[i]].getElementType()
if (_type == 'TEXT_FIELD' ||
_type == 'TEXT_AREA' ||
_type == 'RTF_AREA' ||
_type == 'HTML_AREA' ||
_type == 'TYPE_AHEAD' ||
_type == 'COMBOBOX' ||
_type == 'RADIOS' ||
_type == 'CHECK' ||
_type == 'CALENDAR' ||
_type == 'IMAGE_MEDIA' ||
_type == 'LABEL' ||
_type == 'PASSWORD') {
_datap = forms[_form].elements[_elements[i]].getDataProviderID()
if (_datap) {
_colPos++;
_colNames[_colPos] = _datap;
// _colNames[_colNames.length] = _datap;
if (!/\./.test(_datap)) {
_jsTable = databaseManager.getTable(forms[_form].foundset);
} else { //related field
_relation = _datap.replace(/\.\w*$/, "");
_datap = _datap.match(/(\w*)$/)[0];
_jsTable = databaseManager.getTable(forms[_form].foundset[_relation]);
}
_JSColumn = _jsTable.getColumn(_datap);
if (_JSColumn && _JSColumn.getType() == JSColumn.DATETIME && forms[_form].elements[_elements[i]].format) {
_formats[_colPos] = forms[_form].elements[_elements[i]].format;
// _formats[i] = forms[_form].elements[_elements[i]].format;
}
if (_type != 'LABEL' && _type != "IMAGE_MEDIA" && _type != 'CALENDAR' && !/_AREA$/.test(_type)) {
_vlNames[_colPos] = forms[_form].elements[_elements[i]].getValueListName();
// _vlNames[i] = forms[_form].elements[_elements[i]].getValueListName();
}
}
}
}
return [_colNames, _vlNames, _formats];
}