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,
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:
.createValueBinding(binding));
...
So you don't need to do anything else, the underlying data model is being updated with the selected value from the DropDownList automatically.
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!
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);
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!
Can you provide a more complex create column example that allows dynamically adding an editable column containing dropdown in WebGrid.
The static jsf code is something like this:
Hi!
Here I will post a simplified example that emphasizes on the dynamic column creating.
In JSF:
<ig:gridView id="grid1" dataSource="#{dynGrid.dataSource}" binding="#{dynGrid.grid}">
In Java:
public GridView getGrid() {
this.grid = grid;
// if the grid is empty, it probably means that it hasn't been
// initialized yet
initGrid();
FacesContext context = FacesContext.getCurrentInstance();
// clear the grid
clearGrid();
// set the pagesize
"#{DATA_ROW.firstName}", "firstName");
"#{DATA_ROW.lastName}", "lastName");
"email");
"#{DATA_ROW.phoneNumber}", "phoneNumber");
// ask the grid to rebind itself to its datasource
grid.setHeader(null);
grid.getTemplateItems().clear();
String binding, String sortByCriteria) {
// define the value binding
column.getChildren().add(columnContent);
dataSource = new ArrayList();
"555-1234");
person = new Person("Karin", "Rolfson", "K.Rolfson@mymail.com",
private String firstName = null;
private String email = null;
String phoneNumber) {
this.lastName = lastName;
// Getters and Setters