list = this.getDefaultColumns();
}
columns = new ArrayList();
for (SelectOption option : list)
{
columns.add(new PropertyColumn(new
StringResourceModel(option.getPropertyValue(),
this,
null),
option.getPropertyValue(),
option.getPropertyValue()));
}
if(datatable != null)
{
datatable.remove();
}
datatable = new DefaultDataTable("datatable",
columns,
dataProvider,
20);
add(datatable);
}
private ArrayList getColumnCheckBoxes()
{
if (columnCheckBoxes == null)
{
columnCheckBoxes = new ArrayList();
columnCheckBoxes.add(new SelectOption("columnA",
this.columnA.getObject()));
columnCheckBoxes.add(new SelectOption("columnB",
this.columnB.getObject()));
columnCheckBoxes.add(new SelectOption("columnC",
this.columnC.getObject()));
columnCheckBoxes.add(new SelectOption("columnD",
this.columnD.getObject()));
}
return columnCheckBoxes;
}
/*
By default, columns A and B are selected
*/
private ArrayList getDefaultColumns()
{
ArrayList defaultColumns = new
ArrayList();
defaultColumns.add(new SelectOption("columnA",
this.columnA.getObject()));
defaultColumns.add(new SelectOption("columnB",
this.columnB.getObject()));
return defaultColumns;
}
class SelectOption implements Serializable
{
private static final long serialVersionUID = 1L;
private String propertyValue;
private String displayValue;
/**
* Utility class for storing property and display values for
option
* widgets (e.g. drop down lists, check boxes).
*/
public SelectOption(String propertyValue, String displayValue)
{
this.propertyValue = propertyValue;
this.displayValue = displayValue;
}
// getters/setters
}
}
-Original Message-
From: Shelli Orton
Sent: Tuesday, September 21, 2010 10:49 AM
To: users@wicket.apache.org
Subject: Dynamic Column Datatable - Example
Hi,
I think what I need to do is fairly common. I have a number of
checkboxes that users can select to determine which columns they want
displayed in a datatable.
I've been searching for an example of a dynamic datatable and haven't
been able to find one. I've seen references to a solution in 2008 mail
archives that suggest it might be implemented in 1.4
(http://www.mail-archive.com/users@wicket.apache.org/msg10528.html).
Can anyone confirm that it has been or not? In either case, is there an
example that someone can point me to?
Thanks in advance!
Shelli
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org