Hi.
I have a problem with the JPA, Datasource or TreeGrid if i use TreeModelType.Children. My problem is, that the Treegrid shows the Elements not as tree. All Elements are one underneath the other. Which settings are correct or what is wrong? Here is my code.
	
	
	
	
							
						
					I have a problem with the JPA, Datasource or TreeGrid if i use TreeModelType.Children. My problem is, that the Treegrid shows the Elements not as tree. All Elements are one underneath the other. Which settings are correct or what is wrong? Here is my code.
Code:
	
	final DataSource treeDS = DataSource.get("tree_DataSource");
final Tree tree = new Tree();
tree.setModelType(TreeModelType.CHILDREN);
tree.setChildrenProperty("childrenTreeNodes");	
treeGrid = new TreeGrid();
treeGrid.setData(tree);
treeGrid.setAutoFetchData(true);  
treeGrid.setDataSource(treeDS);   
	        ...
Code:
	
	<DataSource
    ID="tree_DataSource"
    serverConstructor="com.isomorphic.jpa.JPADataSource"
    beanClassName="com.detection.smiths.eapcfg.server.persistence.Tree">
    
    <fields>
        <field name="treeNodeId"     type="sequence" hidden="true"   primaryKey="true" />
        <field name="childrenTreeNodes" multiple="true" type="tree_DataSource"/> 
        <field name="nodeName"   type="text"     title="Name"    required="true"/>
    </fields>
</DataSource>
Code:
	
	@Entity
@Table (name="Tree")
public class Tree
    implements Serializable
{
 
    @Id
    @Column (nullable = false)
    @GeneratedValue (strategy = GenerationType.IDENTITY)
    private Long treeNodeId;
  
    @Column (nullable = false)
    private String nodeName;
    @JoinColumn
    private List<Tree> childrenTreeNodes;
    public Tree ()
    {
    }
    @Override
    public String toString ()
    {
        return getClass().getName()
               + "["
               + "childrenTreeNodes=" + ((getChildrenTreeNodes() == null) ? "null" : getChildrenTreeNodes().toString())
               + ", "
               + "nodeName=" + ((getNodeName() == null) ? "null" : getNodeName().toString())
               + "]";
    }
....
Code:
	
	
final DataSource treeDS = DataSource.get("tree_DataSource");
Record newRecord = new Record();
Record newRecord2 = new Record();
Record[] tl=new Record[1];
tl[0]=newRecord2;
newRecord.setAttribute("nodeName", "A")
newRecord.setAttribute("childrenTreeNodes", tl);
newRecord2.setAttribute("nodeName", "B");
newRecord2.setAttribute("childrenTreeNodes", new Record[0]);
treeDS.addData(newRecord);
Comment