在尝试将数据添加到我创建的表单子列表时,我似乎遗漏了一些东西。
子列表填充了第一行数据,但没有其他内容。
我试过将列表对象用于 ui,但它似乎与表单分开。我的目标是显示一条记录,其中包含与该记录相关的多个子列表(基于保存的搜索)。
任何帮助都会很棒。
谢谢
var mySearch = search1.load({
id: 'customsearch511'
});
var resultSet = mySearch.run();
var list = form.addSublist( {
id: 'custpage_sublist',
type : serverWidget.SublistType.LIST,
label: 'Lines'
});
resultSet.columns.forEach(function(col){// This adds columns to the sublist based on the search results
list.addField({
id: col.name,
label: col.label,
type: serverWidget.FieldType.TEXT
});
});
for(var i in results){
var result = results[i];
for(var k in result.columns){
var test = result.columns[k];
if(result.getText(result.columns[k])){ //This is to get the values of any select field in the search
var fieldValue = result.getText(result.columns[k]
)}
else{
var fieldValue = result.getValue(result.columns[k]
)};
list.setSublistValue({
id: result.columns[k].name,
value: fieldValue,
line: i
});
//Error out after the first row is entered. When this loops back to the second line of the search results.
}
context.response.writePage(form);
你只需要在你的代码中做一些小的修正就可以了。
var a = Number(i);
sublist.setSublistValue({
id: result.columns[k].name,
value: fieldValue,
line: a
});
我已经测试过,它工作正常。
也可以尝试使用“+”进行更高性能的数字转换:
list.setSublistValue({
id: result.columns[k].name,
value: fieldValue,
line: +i
});