Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to sort a group
vlpe
Can you tell me how to add sorting to table group in code shown below<br />
String[] columnNames = new String[colCount];<br />
cn = new String[colCount];<br />
for (int i = 0; i < colCount; i++) {<br />
columnNames
= meta.getColumnName(i + 1);<br />
cn
= columnNames
;<br />
}<br />
<br />
TableGroupHandle group = design.getElementFactory().newTableGroup();<br />
group.setName("GroupPerValue");<br />
group.setKeyExpr(""Floor"");<br />
RowHandle grpHdrHandle = design.getElementFactory().newTableRow(4);<br />
CellHandle tblCellHandle = (CellHandle) grpHdrHandle.getCells().get(0);<br />
//tblCellHandle.setDrop(DesignChoiceConstants.DROP_TYPE_DETAIL);<br />
LabelHandle lbl = efactory.newLabel(null);<br />
lbl.setText("kuku");<br />
tblCellHandle.getContent().add(lbl);<br />
RowHandle grpFtrHandle = design.getElementFactory().newTableRow(4);<br />
CellHandle tblCellHandle2 = (CellHandle) grpFtrHandle.getCells().get(0);<br />
//tblCellHandle2.setDrop(DesignChoiceConstants.DROP_TYPE_DETAIL);<br />
LabelHandle lbl2 = efactory.newLabel("test2");<br />
lbl2.setText("kuku-ruku");<br />
tblCellHandle2.getContent().add(lbl2);<br />
<br />
group.setStringProperty("repeatHeader", "false");<br />
group.setPageBreakAfter("always");<br />
//group.setStringProperty("intervalBase", "6");<br />
//group.setStringProperty("interval", "interval");<br />
//group.setStringProperty("intervalRange", "14, 20");<br />
group.setPageBreakBefore("always-excluding-first");<br />
TableHandle table = efactory.newTableItem("tbl", colCount, 1, rowCount, 0);<br />
//table.setWidth("100%");
Find more posts tagged with
Comments
JasonW
Create your Group like:
TableGroupHandle group = elementFactory.newTableGroup( );
group.setName("MyGroup");
group.setKeyExpr( "row["ORDERNUMBER"]" );
group.setInterval("none");
group.setSortDirection("asc");
Then call one of the functions below
void addSortKey(TableGroupHandle th){
try{
SortKey sk = structFactory.createSortKey();
//sk.setKey("row["CustomerName"]");
sk.setDirection(DesignChoiceConstants.SORT_DIRECTION_ASC);
sk.setKey("if( params["srt"].value){ if( params["srt"].value == 'a' ){ row["CustomerName"]; }else{ row["CustomerCity"];}}");
PropertyHandle ph = th.getPropertyHandle(TableHandle.SORT_PROP);
ph.addItem(sk);
}catch (Exception e){
e.printStackTrace();
}
}
void modSortKey(TableGroupHandle th){
try{
SortKeyHandle sk;
PropertyHandle ph = th.getPropertyHandle(TableHandle.SORT_PROP);
//get number or iterate
sk = (SortKeyHandle)ph.get(0);
sk.setDirection(DesignChoiceConstants.SORT_DIRECTION_DESC);
}catch (Exception e){
e.printStackTrace();
}
}
Jason