ButtonItem saveBtn = new ButtonItem("Save");
saveBtn.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
@Override
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
event.getForm().saveData(new DSCallback() {
@Override
public void execute(DSResponse response, Object rawData, DSRequest request) {
Record rec = response.getData()[0];
JavaScriptObject rawItems = rec.getAttributeAsJavaScriptObject("items");
String html = StringUtil.asHTML(new JSONEncoder().encode(rawItems));
SC.say("Record saved with items:" + html);
}
});
}
});
exampleForm.setItems(orderID, orderDate, items, saveBtn);
Criteria orderCriteria = new Criteria();
orderCriteria.addCriteria("orderID", 1);
orderDS.fetchData(orderCriteria, new DSCallback() {
@Override
public void execute(DSResponse response, Object rawData, DSRequest request) {
DynamicForm exampleForm = (DynamicForm) Canvas.getById("exampleForm");
exampleForm.editRecord(response.getData()[0]);
}