-
1. Re: Insert a row to a column in HtmlDataTable
nbelaevski Jul 13, 2010 5:36 PM (in response to r.val)1 of 1 people found this helpfulHi Raul,
You can insert BR tag if it's ok for row1 & row2 to be in the same table cell. If that's not so, check "breakBefore" attribute and subTable component.
-
2. Re: Insert a row to a column in HtmlDataTable
r.val Jul 14, 2010 5:32 AM (in response to nbelaevski)Hi Nick, thank you for the tip.
But, after some analysis, I've found a good solution for my issue.
The real problem was on the way the component iterates on the rows of the list.
I want to put my solution on the forum because maybe can be useful for someone else.
My problem was to use a list of records instead of a list of beans for my data table.
So, I've made a List<ArrayList<String>> customRows with the rows of my record, and an header list.
The final code is:
public void populateDataTable() { // <h:dataTable value="#{dataEntity.customRows}" var="col">. HtmlDataTable dataTable = new HtmlDataTable(); dataTable.setValueExpression("value", createValueExpression("#{dataEntity.customRows}", List.class)); dataTable.setVar("col"); HtmlColumn headerCol = null; for(int i = 0; i<header.size(); i++){ // <h:column> for 'header.get(i)' column. headerCol = new HtmlColumn(); // <h:outputText value="header.get(i)"> for <f:facet name="header"> of 'header.get(i)' column. HtmlOutputText headerText = new HtmlOutputText(); headerText.setValue(header.get(i)); headerCol.setHeader(headerText); dataTable.getChildren().add(headerCol); // <h:outputText value="#{col[i]}"> for the body of 'header.get(i)' column. HtmlOutputText outputText = new HtmlOutputText(); outputText.setValueExpression("value", createValueExpression("#{col["+i+"]}", String.class)); headerCol.getChildren().add(outputText); } // Finally add the datatable to a panelGroup dataTableGroup = new HtmlPanelGroup(); dataTableGroup.getChildren().add(dataTable); }
Finally, I hope this can be useful to someone, and thanks again.
-
3. Re: Insert a row to a column in HtmlDataTable
nbelaevski Jul 14, 2010 6:37 AM (in response to r.val)There's no need to create nested data table, subTable can do this - check livedemo examples.
-
4. Re: Insert a row to a column in HtmlDataTable
r.val Jul 16, 2010 5:40 AM (in response to nbelaevski)Ok, thank you for the tip. I'll try your solution too.
Thanks again