Is there an easy way to populate the ListGridField that's being edited by the SelectItem with the selected record of the SelectItem instead of just the value field?
Announcement
Collapse
No announcement yet.
X
-
Here's what I ended up implementing. I was hoping that there would be some way to drop the entire record from the select item into the list grid record.
Code:ListGridField listGridField = new ListGridField("activity", "Activity"){{ setValueField("id"); setDisplayField("qualifiedName"); setRequired(true); setOptionDataSource(dsActivities); setDataPath("activity/id"); addChangedHandler(new com.smartgwt.client.widgets.grid.events.ChangedHandler() { @Override public void onChanged(com.smartgwt.client.widgets.grid.events.ChangedEvent event) { Record record = grdActivities.getEditedRecord(event.getRowNum()).getAttributeAsRecord("activity"); ListGridRecord record0 = event.getItem().getSelectedRecord(); record.setAttribute("type", record0.getAttribute("type")); record.setAttribute("pool", record0.getAttributeAsRecord("pool")); } }); }};
Comment
-
There isn't anything built in to pull all fields from the selectItem into the listGrid record automatically. Your code basically looks fine, except we'd recommend you use ListGrid.setEditValue() or setEditValues() to populate the other fields in the record rather than doing record.setAttribute directly. That'll make sure the values get updated as "editValues" which then get saved through the normal flow, which'll handle a databound save, validation, etc.
Regards
Isomorphic Software
Comment
Comment