Hello. How can I make in DynamicForm relation field which allow editing many to many relations? From what I see in documentation I have to make my own Canvas based component which I can add to DynamicForm as CanvasItem with my own expected behaviour (two listgrids with drag and drop or one listgrid with “add”, “remove” buttons), am I right?
One to one and many to one I can do with SelectItem however I’m not able to setup custom display field.
final SelectItem parentField=new SelectItem("parent");
parentField.setOptionDataSource(PersonDataSource.getInstance2());
parentField.setWidth(200);
parentField.setPickListWidth(400);
ListGridField categoryField=new ListGridField("category");
ListGridField nameField=new ListGridField("itemName");
ListGridField costField=new ListGridField("unitCost");
ListGridField unitsField=new ListGridField("units");
ListGridField inStockField=new ListGridField("inStock");
ListGridField allKeys=new ListGridField("keys", "keys");
allKeys.setType(ListGridFieldType.TEXT);
allKeys.setCellFormatter(new CellFormatter() {
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
return record.getAttributeAsString("itemName")+" ("+record.getAttributeAsString("unitCost")+" "+record.getAttributeAsString("units")+")";
}
});
parentField.setPickListFieldsFields(nameField, costField, unitsField, inStockField, allKeys);
parentField.setValueField("id");
parentField.setDisplayField("keys");
parentField.setStartRow(true);
parentField.setEndRow(true);
I would like to show content of “keys” column as display value of drop down element. I also played little bit with Hint on SelectItem component however I’m not able to fetch selected row data from SelectItem element. Is it feasible for example in ChangeHandler of SelectItem component to get selected row of underlying ListGrid?
TNX
Pavel