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.
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
cel1.getChildren().add(valor1);
cel2.getChildren().add(valor2);
ren1.getCells().add(cel1);
ren1.getCells().add(cel2);
-Taz.
Hi,
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");
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
Try with calling that method instead of the createColumn method in initGrid(). It is used the same way like createColumn() and adds an Infragistics DropDownList to the column.
String header, String binding, String sortByCriteria) {
columnHeader.setValue(header);
column.setHeader(columnHeader);
dropDown.setDataSource(dropDownSource);
.createValueBinding(binding));
column.getChildren().add(dropDown);
// if there is a sortby criteria
column.setSortBy(sortByCriteria);
private List createSelectionList() {
result.add(new SelectItem("United States"));
result.add(new SelectItem("United Kingdom"));
I hope this will help you!
Regards!
Thanks for your reply!! A related question though:
How can I set this dynamic grid as "editable" programatically. The idea is that once these UIInput components(dropdowns) nested within the columns are edited, the underlying data model is also updated automatically.
Basically, its could be like adding the tag <ig:gridEditing /> to the grid from code.
Thanks and Regards!
When you call the createColumnWithDropDown() method with the appropriate parameters, i.g.
Column column5 = createColumnWithDropDown(context, "Country", "#{DATA_ROW.country}", null);
then you bind the specified binding (in this case #{DATA_ROW.country} ) to the value property of the DropDown:
...
So you don't need to do anything else, the underlying data model is being updated with the selected value from the DropDownList automatically.
I need a dynamically created grid where the first column should allow row selection. This should be equivalent to adding <ig:columnSelectRow showSelectAll="true" /> tag to the grid. How can this be added programatically ?
This tag if inserted statically to jsp page does not work after columns are added at run time:
<ig:gridView id="grid1" dataSource="#{dynGrid.dataSource}" binding="#{dynGrid.grid}"> <ig:columnSelectRow showSelectAll="true" /> </ig:gridView>
regards,
You could turn to that thread. I suppose the situation is very similar.
Thanks!
The behavior you've described doesn't seem to be right, based on what I'm seeing. So that we can investigate this in more detail, and provide you with a fix once one becomes available, please submit a support request to Infragistics Developer Support. You can provide the URL of this thread in your support request, so that we know the two are related.
Are you just informing that there is no solution at present ?
Here is what I tried:
com.infragistics.faces.grid.component.html.HtmlColumn aColumn = (com.infragistics.faces.grid.component.html.HtmlColumn)application.createComponent(com.infragistics.faces.grid.component.html.HtmlColumn.COMPONENT_TYPE);HtmlColumnSelectRow col1Value = (HtmlColumnSelectRow) application.createComponent(HtmlColumnSelectRow.COMPONENT_TYPE);col1Value.setShowSelectAll(true);aColumn.setHeader(col1Value);aColumn.getChildren().add(col1Value);grid.getTemplateItems().add(aColumn);
This adds a column with checkbox option to select a row, grid.getSelectedRows() function works fine in bean.
However, the checkbox that should appear in header row to allow selection of all rows when selected, does not appear.
Can you suggest how to make the header row checkbox appear and work?
Regards