我正在尝试在ComboBoxItem
的下拉菜单中添加新的空行,数据来自数据库。空白行,其值为“-1”或null
为DSResponse
的响应。
Criteria c2 = new Criteria();
OptionListDataSource attrTypeds = OptionListDataSource
.getInstance(FieldNames.ATTRIBUTE_TYPE_FIELD);
attrTypeds.fetchData (c2, new DSCallback() {
@Override
public void execute(final DSResponse response,
final Object rawData, final DSRequest request) {
Record[] recList = response.getData();
if (recList != null) {
StringBuilder builder= new StringBuilder();
int recListLength = recList.length;
Window.alert("Lenght of Response is : "+recListLength);
for(int i=0;i<recListLength;i++){
Window.alert("Data at "+i+" : "+recList[i].getAttribute(FieldNames.ID_FIELD));
Record record = recList[i];
JavaScriptObject js = record.getJsObj();
JSONObject jsonn = new JSONObject(js);
builder.append(jsonn.toString());
}
Window.alert("JSON Response : "+builder);
recList[recListLength+1].setAttribute(FieldNames.ID_FIELD, "-1");
Window.alert("Updated lenght of Response is : "+recList.length);
Window.alert("Updated Value at last position : "+recList[recList.length].getAttribute(FieldNames.ID_FIELD));
initialValuesMap.put(FieldNames.ATTRIBUTE_TYPE_ID_FIELD,recList[recList.length].getAttribute(FieldNames.ID_FIELD));
}
form.editNewRecord(initialValuesMap);
}
});
Window.alert("JSON Response : "+builder);
这句话后我无法看到警报。我做错了什么?我只想将空白/ null
数据添加到Record[] recList
。此外,是否有任何Criteria
。我使用的是smartgwt版本3
答案 0 :(得分:0)
如果您使用 SelectItem 而不是 ComboBoxItem ,则默认情况下会出现空白选项,而您不会需要做任何事情。