Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
how to bind a dataset to a dataitem in a grid
haglo
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">I use eclipse 4.4.1, windows 8.1, java 7, birt 4.4.1 and the demo-database of birt.</span></p>
<p> </p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">I have a report in which i add a library.</span></p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">The library has a grid with many dataitems binded to different datasets.</span></p>
<p> </p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">How can I add a dataset to a dataitem with java.</span></p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">I want to make all with java.</span></p>
<p> </p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">My code in the moment is</span></p>
<pre class="_prettyXprint _lang-">
for (Object handleObject : libraryHandleOrder.getComponents()
.getContents()) {
if (handleObject instanceof GridHandle) {
reportDesignHandle.getBody().add(
(DesignElement) ((GridHandle) handleObject)
.copy());
((GridHandle) handleObject).setDataSet(tmpOdaDataSetHandle);
.....
SlotHandle grRows = tmpGridHandle.getRows();
java.util.Iterator rowIterator = grRows.iterator();
while (rowIterator.hasNext()) {
Object rowSlotContents = rowIterator.next();
SlotHandle cellSlot = ((RowHandle) rowSlotContents)
.getCells();
java.util.Iterator cellIterator = cellSlot
.iterator();
while (cellIterator.hasNext()) {
Object cellSlotContents = cellIterator.next();
SlotHandle cellContentSlot = ((CellHandle) cellSlotContents)
.getContent();
java.util.Iterator cellContentIterator = cellContentSlot
.iterator();
while (cellContentIterator.hasNext()) {
Object cellContent = cellContentIterator
.next();
if (cellContent instanceof DataItemHandle) {
((DataItemHandle) cellContent)
.setDataSet(tmpOdaDataSetHandle);
}
}
}
}</pre>
<p>from code above is the following codeimportant, but it don't work at me</p>
<pre class="_prettyXprint _lang-">
if (cellContent instanceof DataItemHandle) {
((DataItemHandle) cellContent).setDataSet(tmpOdaDataSetHandle);
}
</pre>
Find more posts tagged with
Comments
JFreeman
<p>Are you receiving any errors with this code?</p>
<p> </p>
<p>What is the behavior you are seeing when this is not working?</p>
haglo
<p>I have solved the problem<br>
the problem was, that there was another Grid in a Cell of the Grid.</p>
<p> </p>
<p>This is now my working Code<br><br>
</p>
<pre class="_prettyXprint _lang-">
public void iterateRecursiveThroughGrid(GridHandle gridHandle,
OdaDataSetHandle odaDataSetHandle1, OdaDataSetHandle odaDataSetHandle2) {
try {
gridHandle.setDataSet(odaDataSetHandle1);
SlotHandle grRows = gridHandle.getRows();
java.util.Iterator rowIterator = grRows.iterator();
while (rowIterator.hasNext()) {
// Get RowHandle objects.
Object rowSlotContents = rowIterator.next();
SlotHandle cellSlot = ((RowHandle) rowSlotContents).getCells();
java.util.Iterator cellIterator = cellSlot.iterator();
while (cellIterator.hasNext()) {
Object cellSlotContents = cellIterator.next();
SlotHandle cellContentSlot = ((CellHandle) cellSlotContents)
.getContent();
java.util.Iterator cellContentIterator = cellContentSlot
.iterator();
while (cellContentIterator.hasNext()) {
Object cellContent = cellContentIterator.next();
if (cellContent instanceof GridHandle) {
((GridHandle) cellContent)
.setDataSet(odaDataSetHandle1);
iterateRekursiveThroughGrid((GridHandle) cellContent, odaDataSetHandle1, odaDataSetHandle2);
}
if (cellContent instanceof DataItemHandle) {
((DataItemHandle) cellContent)
.setDataSet(odaDataSetHandle1);
}
if (cellContent instanceof TableHandle) {
((TableHandle) cellContent)
.setDataSet(odaDataSetHandle2);
}
}
}
}
} catch (SemanticException e) {
e.printStackTrace();
}
}
</pre>
JFreeman
<p>Can you check what type of class cellContent is registering as?</p>
<p>Something like: cellContent.getClass().getName();</p>
haglo
<p>With </p>
<pre class="_prettyXprint _lang-">
if (cellContent instanceof GridHandle) {
System.out.println("GridClassName: " + cellContent.getClass().getName());
}
</pre>
<p>I get:</p>
<p>GridClassName: org.eclipse.birt.report.model.api.GridHandle</p>
JFreeman
<p>I'm glad to hear you got it solved.</p>
<p>Thanks for posting your solution.</p>