hello, i need to populate a GridView dynamically, i've created the colums already, but i don't know how to fill the rows???
I 've tried with Cells, but i don't find a function to put the label i want to show,
i got the following code:
tabla=new HtmlGridView(); HtmlOutputText tit=new HtmlOutputText(); tit.setValue("Monitoreo a Caja"); tabla.setHeader(tit); com.infragistics.faces.grid.component.Column col1=new com.infragistics.faces.grid.component.Column(); HtmlOutputText enc1=new HtmlOutputText(); enc1.setValue("Header 1"); col1.setHeader(enc1); tabla.getColumns().add(col1); com.infragistics.faces.grid.component.Column col2=new com.infragistics.faces.grid.component.Column(); HtmlOutputText enc2=new HtmlOutputText(); enc2.setValue("Header2"); col2.setHeader(enc2); tabla.getColumns().add(col2);
HtmlOutputText valor1=new HtmlOutputText(); valor1.setValue("valor1"); HtmlOutputText valor2=new HtmlOutputText(); valor2.setValue("valor2"); com.infragistics.faces.grid.component.RowItem ren1=new com.infragistics.faces.grid.component.RowItem(); com.infragistics.faces.grid.component.Cell cel1=new com.infragistics.faces.grid.component.Cell(); com.infragistics.faces.grid.component.Cell cel2=new com.infragistics.faces.grid.component.Cell();
HOW DO I PUT THE LABEL???????? ren1.getCells().add(cel1); ren1.getCells().add(cel2); tabla.getRows().add(ren1);
thanks.
Hi,
My first advice would be to have a look at our example on Dynamic Grid at our NetAdvantage for JSF Samples site. There you can find a working example demonstrating a Dynamic Grid under WebGrid/Dynamic Grid. The source is available in the INSTALL_FOLDER/demos/src/main/... folder on your computer. If after this there are still any questions do not hesitate to ask for help.
Regards!
I have a similar requirement of creating the grid dynamically (both rows and columns). For this I have created a gridView binding and populating the grid in my backing bean. But unfortunately I am not getting sucess. Could you please help me in this. Basically what sould be the dataSource and how to create grid view in backing bean. If someone could share a sample code that will be very much helpful.
At runtime I get the information of number of rows and columns to be displayed. As of now I tried in the following way:
Web page:
binding="#{testBean.scorePointCalculationPointGridView}"
dataSource="#{testBean.scorePointCalculationPointDataModel}"
>
Backing Bean:
private DataModel scorePointCalculationPointDataModel;
createDynamicGrid();
}
private void createDynamicGrid(){
List tempList = new ArrayList<String>();
scorePointCalculationPointDataModel = new ListDataModel(dataModel);
HtmlOutputText tit=new HtmlOutputText();
scorePointCalculationPointGridView.setHeader(tit);
HtmlOutputText enc1=new HtmlOutputText();
col1.setHeader(enc1);
scorePointCalculationPointGridView.getColumns().add(col1);
valor1.setValue("valor1");
cel1.getChildren().add(valor1);
ren1.getCells().add(cel1);
scorePointCalculationPointGridView.getRows().add(ren1);
When I am executing this then I am not getting the rows displayed. Only the heading of the column and a blank row.
Thank you
Kaushal
Hello,
You have to add the labels to the cells, here are the two lines you can add to you existing code to display labels.
com.infragistics.faces.grid.component.Cell cel2=new com.infragistics.faces.grid.component.Cell();
//Add Component to the cells
cel2.getChildren().add(valor2);
ren1.getCells().add(cel2);
-Taz.