Hello,
A custom data source does not work with a TreeGrid for me.
This is the code I use to return the tree data from the data source:
This is what happens:
The last two nodes should be leaves without children, but for some reason they are displayed as folders with children (which do not exist). When I click one of the last two nodes to expand it, the TreeGrid becomes empty.
This is how it should look like:
I can achieve this result easily without using a DataSource:
This works as expected. The main difference is that I used a Tree and added it to the TreeGrid which is not possible with a DataSource. What am I doing wrong?
How can I achieve this using a custom data source? Is this even possible?
DSResponse.setData() only accepts an array of records. Is there a way to return a tree model from a DataSource rather than an array of records?
Can someone give a working example of a TreeGrid with a custom data source?
A custom data source does not work with a TreeGrid for me.
This is the code I use to return the tree data from the data source:
Code:
@Override protected Object transformRequest( DSRequest request ) { if ( request.getOperationType() == DSOperationType.FETCH ) { VorgangAuftragNode v1 = new VorgangAuftragNode(); v1.setID( "v1" ); v1.setParentID( "root" ); v1.setData( new Vorgang( "Haus bauen", 1 ) ); VorgangAuftragNode v2 = new VorgangAuftragNode(); v2.setID( "v2" ); v2.setData( new Vorgang( "Baum bauen", 2 ) ); v2.setParentID( "v1" ); VorgangAuftragNode v3 = new VorgangAuftragNode(); v3.setID( "v3" ); v3.setData( new Auftrag( "Loch buddeln", 1, new Mitarbeiter( 1, "Bernhold Besenstiel" ), 33d, 15d, "Bla", true ) ); v3.setParentID( "v2" ); VorgangAuftragNode v4 = new VorgangAuftragNode(); v4.setID( "v4" ); v4.setData( new Auftrag( "Baum buddeln", 2, new Mitarbeiter( 1, "Bernhold Besenstiel" ), 44d, 15d, "Bla", true ) ); v4.setParentID( "v2" ); DSResponse response = new DSResponse(); response.setStatus( 0 ); response.setAttribute( "clientContext", request.getAttributeAsObject( "clientContext" ) ); response.setData( new VorgangAuftragNode[]{ v1, v2, v3, v4 } ); processResponse( request.getRequestId(), response ); } return request.getData(); }
The last two nodes should be leaves without children, but for some reason they are displayed as folders with children (which do not exist). When I click one of the last two nodes to expand it, the TreeGrid becomes empty.
This is how it should look like:
I can achieve this result easily without using a DataSource:
Code:
VorgangAuftragNode v1 = new VorgangAuftragNode(); v1.setID( "v1" ); v1.setParentID( "root" ); v1.setData( new Vorgang( "Haus bauen", 1 ) ); VorgangAuftragNode v2 = new VorgangAuftragNode(); v2.setID( "v2" ); v2.setData( new Vorgang( "Baum bauen", 2 ) ); v2.setParentID( "v1" ); VorgangAuftragNode v3 = new VorgangAuftragNode(); v3.setID( "v3" ); v3.setData( new Auftrag( "Loch buddeln", 1, new Mitarbeiter( 1, "Bernhold Besenstiel" ), 33d, 15d, "Bla", true ) ); v3.setParentID( "v2" ); VorgangAuftragNode v4 = new VorgangAuftragNode(); v4.setID( "v4" ); v4.setData( new Auftrag( "Baum buddeln", 2, new Mitarbeiter( 1, "Bernhold Besenstiel" ), 44d, 15d, "Bla", true ) ); v4.setParentID( "v2" ); Tree treeModel = new Tree(); treeModel.setModelType( TreeModelType.PARENT ); treeModel.setRootValue( "root" ); treeModel.setData( new VorgangAuftragNode[]{ v1, v2, v3, v4 } ); treeGrid.setData( treeModel );
How can I achieve this using a custom data source? Is this even possible?
DSResponse.setData() only accepts an array of records. Is there a way to return a tree model from a DataSource rather than an array of records?
Can someone give a working example of a TreeGrid with a custom data source?
Comment