Pointbreak schrieb:
The public interface of the inmethod DataGrid/DefaultDataGrid does not
seem to provide functionality to expand the number of rows after an
ajax-call that e.g. adds data to the underlying datasource. Is there a
way to tell the DataGrid that the underlying datasource may have
changed, to the effect that the existing row count is not valid anymore?
I.e. like markAllItemsDirty(), but then telling the grid to reload the
entire underlying model, including rowcount, instead of only the
individual rows?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

I tackled a similar problem (an "add" button for an editable datagrid) the following way:

- create a new object with reflection
- insert it in the backing list (model)
- call update on the grid
- add the grid to the requesttarget

public class MyDataGrid extends DecoratedDataGrid
{
protected List rawList;

protected final Class modelAsClass;

public MyDataGrid(String id, String title, String buttonTitle, List<?> list,
     List<IGridColumn> columns, final Class<?> modelAsClass)
 {
super(id, title, buttonTitle, new MyDataProviderAdapter(new ListDataProvider(list)),
       columns, modelAsClass);
   log.debug("creating grid for type " + modelAsClass.getSimpleName()
+ " no of columns: " + columns.size() + " size of datalist: " + list.size());
   this.rawList = list;
 }

@Override
protected void onAddRow(AjaxRequestTarget target, Form<?> form)
 {
   Object obj = modelAsClass.newInstance();

   rawList.add(obj);
log.debug("object of class " + modelAsClass.getName() + " successfully inserted");
   update();
   target.addComponent(getGrid());
 }
}

This takes place in a custom subclass of the defaultdatagrid. The onAddRow method is called from an ajaxbutton (onsubmit)
I hope this helps

--
Thierry Peng
  ________    __  _________________________________________________
 / ____/ /   / / / / ____/   GLUE Software Engineering AG
/ / __/ /   / / / / __/     Zieglerstr. 34, 3007 Bern,  Switzerland
/ /_/ / /___/ /_/ / /___    Phone: +41-(0)31/385 30 34    Fax: 30 18
\____/_____/\____/_____/___mailto: p...@glue.ch


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to