On Mon, 15 Mar 2010 15:06 +0100, "Thierry Peng" <p...@glue.ch> wrote: > 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
You must be doing something else in addition to that (or I am missing something). As far as I can see, the DefaultDataGrid class will not ask its model/datasource for a new rowcount when you call update(). Hence the call to update() will not result in the addition of a row to the grid, even though you added the row to your model. Are you sure you are not replacing the entire dataGrid in e.g. your getGrid() call? --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org