Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » crosstab row headers(Birt crosstab row headers using deapi)
crosstab row headers [message #1722344] Thu, 04 February 2016 08:35
Himanshu Salgaonkar is currently offline Himanshu SalgaonkarFriend
Messages: 2
Registered: February 2016
Junior Member
hello,

I have creadted a crosstab which dynamically arranges rows (3 rows in my example) and does grouping according which is working perfectly
index.php/fa/24893/0/
but when adding headers to the rows content,headers are arranged one below the other

i used :-
LabelHandle labelHandle = designFactory.newLabel(null);
labelHandle.setText("Column"+(i+1));
xtabHandle.getHeader().addContent(labelHandle);

inside loop where I add row levels to crosstab

here is the code:-

void buidCube() throws SemanticException
{
// -----------step(1):------------create new cube
TabularCubeHandle cubeHandle = designHandle.getElementFactory().newTabularCube("MyCube");
// -----------step(2):------------set default dataset to cube
cubeHandle.setDataSet((DataSetHandle) designHandle.getDataSets().get(0));
// -----------step(3):------------add cube to report(now you can see// cube in data explorer)
designHandle.getCubes().add(cubeHandle);

// -----------step(4):------------create crosstab(and assign// 'cubeHandle' otherwise it will give error)
ExtendedItemHandle xtab = CrosstabExtendedItemFactory.createCrosstabReportItem(designHandle, cubeHandle,"MyCrosstab");

// -----------step(5):------------add crosstab to report
designHandle.getBody().add(xtab);

// -----------step(6):------------take handel of crosstab to modify it
IReportItem reportItem = xtab.getReportItem();
CrosstabReportItemHandle xtabHandle = (CrosstabReportItemHandle) reportItem;

TabularHierarchyHandle hierarchy;
TabularLevelHandle level = null;
DimensionViewHandle dvh;
LevelViewHandle levelViewHandle;
CrosstabCellHandle cellHandle;
DesignElementHandle eii;
ComputedColumn bindingColumn;
ComputedColumnHandle bindingHandle;
DataItemHandle dataHandle;

// To add new group in dimension
// -----------step(7):------------create new dimension(i.e. group)
TabularDimensionHandle dimension = designFactory.newTabularDimension(null);
// -----------step(8):------------set new dimension to cube
cubeHandle.add(TabularCubeHandle.DIMENSIONS_PROP, dimension);
dimension.setTimeType(false);

// To add new hierarchy in group
dimension.add(TabularDimensionHandle.HIERARCHIES_PROP,designFactory.newTabularHierarchy(null));
hierarchy = (TabularHierarchyHandle) dimension.getContent(TabularDimensionHandle.HIERARCHIES_PROP, 0);
hierarchy.setDataSet((DataSetHandle) designHandle.getDataSets().get(0));

dvh = xtabHandle.insertDimension(dimension,ICrosstabConstants.ROW_AXIS_TYPE, 0);




/* sai */
for (int i = 0; i < colNames.size(); i++) //ArrayList<String> colNames = new ArrayList<String>(); //in colNames I stored column names to be displayed
{

hierarchy.add(TabularHierarchyHandle.LEVELS_PROP,designFactory.newTabularLevel(dimension, null));
level = (TabularLevelHandle) hierarchy.getContent(TabularHierarchyHandle.LEVELS_PROP, i);
level.setName("Column" + (i + 1));
level.setColumnName(colNames.get(i));
level.setDataType(DesignChoiceConstants.COLUMN_DATA_TYPE_STRING);

levelViewHandle = dvh.insertLevel(level, i);

cellHandle = levelViewHandle.getCell();

// To binding data to crosstab cell
eii = xtabHandle.getModelHandle();
bindingColumn = StructureFactory.newComputedColumn(eii,level.getName());
bindingHandle = ((ReportItemHandle) eii).addColumnBinding(bindingColumn, false);
bindingColumn.setDataType(level.getDataType());
String exp = "dimension['" + dimension.getName() + "']['"+ level.getName() + "']";
bindingColumn.setExpression(exp);
bindingColumn.setDisplayName("Column"+(i+1));

dataHandle = designFactory.newDataItem(level.getName());
dataHandle.setResultSetColumn(bindingHandle.getName());

cellHandle.addContent(dataHandle);
LabelHandle labelHandle = designFactory.newLabel(null);
labelHandle.setText("Column"+(i+1));
xtabHandle.getHeader().addContent(labelHandle);
}
}

i am getting this output
index.php/fa/24893/0/

I want this
index.php/fa/24894/0/
Previous Topic:Print background image with browser print function
Next Topic:Drop and Add Table Again
Goto Forum:
  


Current Time: Wed Apr 24 18:16:03 GMT 2024

Powered by FUDForum. Page generated in 0.03029 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top