Using 5.0-p20150731 PowerEdition/Browser: Chrome
We have a Treenode that shows the Title and a SelectItem (or TextItem) on the children.
When we change the SelectItem and click anywhere outside, the title of this node disappears. However, the title does not disappear when we fill the TextItem.
We found the problem when we are trying to create a simple text by removing the following line:
selectItem.setAddUnknownValues(false);
We have a Treenode that shows the Title and a SelectItem (or TextItem) on the children.
When we change the SelectItem and click anywhere outside, the title of this node disappears. However, the title does not disappear when we fill the TextItem.
We found the problem when we are trying to create a simple text by removing the following line:
selectItem.setAddUnknownValues(false);
Code:
private VLayout mainLayout = new VLayout(); private Canvas canvas = new Canvas(); private TreeNode createNode(String name, String id, String parentId, int type) { TreeNode node = new TreeNode(); node.setID(id); node.setAttribute("Name", name); node.setAttribute("VehicleBehaviorId", id); node.setAttribute("ActionType", type); node.setAttribute("ParentId", parentId); node.setEnabled(true); return node; } public Form() { Map<String, String> codeValueMap = new LinkedHashMap<String, String>(); codeValueMap.put("0", "Select..."); codeValueMap.put("1", "Option 1"); codeValueMap.put("2", "Option 2"); Tree tree = new Tree(); tree.setModelType(TreeModelType.PARENT); tree.setNameProperty("Name"); tree.setIdField("VehicleBehaviorId"); tree.setParentIdField("ParentId"); tree.setData(new TreeNode[] { // Motor createNode("Parent", "id", "1", 0), createNode("Select an option here ->", "id1", "id", 1), createNode("Then, click here ->", "id2", "id", 2) }); TreeGrid treeGrid = new TreeGrid(); treeGrid.setWidth100(); treeGrid.setHeight100(); treeGrid.setEditOnFocus(true); TreeGridField nameField = new TreeGridField("Name"); nameField.setWidth("60%"); final TreeGridField actionField = new TreeGridField("Value"); actionField.setWidth("40%"); actionField.setCanEdit(true); actionField.setValueMap(codeValueMap); treeGrid.setData(tree); treeGrid.getTree().openAll(); treeGrid.setFields(nameField, actionField); treeGrid.setEditorCustomizer(new ListGridEditorCustomizer() { @Override public FormItem getEditor(ListGridEditorContext context) { Record rec = context.getEditedRecord(); int type = rec.getAttributeAsInt("ActionType"); switch (type) { case 0: return null; case 1: SelectItem selectItem = new SelectItem(); selectItem.setAddUnknownValues(false); return selectItem; default: return new TextItem(); } } }); canvas.setHeight100(); canvas.addChild(treeGrid); mainLayout.setWidth100(); mainLayout.setHeight100(); mainLayout.addMember(canvas); this.addChild(mainLayout); }
Comment