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)
Table binding with java
BlazK
<p>I open an existing report and add a table that should show allready present dataset.</p>
<p> </p>
<p>I created new table and set it to dataset "Data".</p>
<p> </p>
<div>
<pre class="_prettyXprint">
TableHandle table = designFactory.newTableItem( "table", 6 );
table.setWidth( "100%" );
table.setDataSet( designHandle.findDataSet( "Data" ) ); </pre>
<div>
<pre class="_prettyXprint">
ArrayList cols = new ArrayList();
cols.add("device");
cols.add("duration");
cols.add("lastseen");
cols.add("sample"); //these are the same names that are in the dataset</pre>
</div>
<div>
<pre class="_prettyXprint">
RowHandle tableheader = (RowHandle) table.getHeader( ).get( 0 );
for( int i=0; i < cols.size(); i++ )
{
LabelHandle label1 = designFactory.newLabel( (String)cols.get(i) );
label1.setText((String)cols.get(i));
CellHandle cell = (CellHandle) tableheader.getCells( ).get( i );
cell.getContent( ).add( label1 );
}
// table detail
RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );
for( int i=0; i < cols.size(); i++ )
{
CellHandle cell = (CellHandle) tabledetail.getCells( ).get( i );
DataItemHandle data = designFactory.newDataItem( "data_"+(String)cols.get(i) );
data.setResultSetColumn( (String)cols.get(i));
cell.setName((String)cols.get(i));
cell.getContent( ).add( data );
}
designHandle.getBody( ).add( table );</pre>
</div>
<p> </p>
</div>
<p> </p>
<p>The problem is that when inspecting xml and binding in property editor dataset is selected, but I do not have any Data Column Binding. If I select None and then again to my dataset I get the bindings.</p>
<p> </p>
<p>How to fix this in java, please give code example, I tried a buny of setProperty and setBinding to no avail.</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>Thanks </p>
Find more posts tagged with
Comments
BlazK
<p>I solved this problem</p>
<p> </p>
<div>
<pre class="_prettyXprint">
ComputedColumn cs1 = null;
for( int i=0; i < cols.size(); i++)
{
cs1 = StructureFactory.createComputedColumn();
cs1.setName((String)cols.get(i));
cs1.setExpression("dataSetRow["" + (String)cols.get(i) + ""]");
computedSet.addItem(cs1);
}</pre>
</div>
<p>It is in example, but on first look I tought it is for computed column, but it is used for bindings to.</p>
<p> </p>
<p>It creates</p>
<div>
<pre class="_prettyXprint">
<list-property name="boundDataColumns">
<structure>
<property name="name">device</property>
<expression name="expression">dataSetRow["device"]</expression>
</structure></pre>
<p>Hope it helps and clears what it does to someone.</p>
</div>