如何编辑DSResponse数据

时间:2016-06-23 09:19:32

标签: java smartgwt

我正在尝试在ComboBoxItem的下拉菜单中添加新的空行,数据来自数据库。空白行,其值为“-1”或nullDSResponse的响应。

        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

1 个答案:

答案 0 :(得分:0)

如果您使用 SelectItem 而不是 ComboBoxItem ,则默认情况下会出现空白选项,而您不会需要做任何事情。