We have a selectitem which uses a composite key. When we save the selectitem we need the id to be passed in along with the type in the return json. How is this possible?
Here's some code with a few attempts we've made to achieve this:
basic version, doesn't return type on saving of new item.
multiple primary keys in datasource, doesn't work:
This works, but makes 2 posts.
Here's some code with a few attempts we've made to achieve this:
basic version, doesn't return type on saving of new item.
Code:
fields.add(new SelectItem("report", "Report"){{ setRequired(true); setDataPath("report/id"); setValueField("id"); setDisplayField("name"); setOptionDataSource(new DataSource("theUrl")); }});
Code:
setOptionDataSource(new DataSource("theUrl"){{ setFields(new DataSourceTextField("id"){{ setPrimaryKey(true); }}, new DataSourceTextField("type"){{ setPrimaryKey(true); }}); }});
Code:
selectitem.addChangedHandler(new ChangedHandler(){ @Override public void onChanged(ChangedEvent event) { form0.getField("report.type").setValue(event.getItem().getSelectedRecord().getAttribute("type")); } }); fields.add(new HiddenItem("report.type"){{ setDataPath("report/type"); setOptionDataSource(new DataSource("theUrl")); }});
Comment