On Mon, 15 Mar 2010 16:06 +0100, "Thierry Peng" <p...@glue.ch> wrote:
> Pointbreak schrieb:
> > 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
> >
> >   
> nope, there is no magic in the getGrid() method. it only returns the 
> grid. If I read the update() method
> correctly I may even omit that call. So, the target.addComponent(grid) 
> is sufficient
> I'm using the inmethod-grid-1.4-rc7 with some extensions. wicket version 
> is 1.4.6

Ok thanks for your help. The problem is that inmethod 's call to
IDataSource.query() asks for the rows upto the last known total row
count. In your case that probably does not matter, since you just return
an iterator over the entire datasource, and update the rowcount
accordingly. I work with very large datasources, and unknown rowcounts.
I can workaround this issue by providing the page-size to my datasource,
so that I can fix the IQuery.getCount() asked by inmethod. Not a nice
solution, but will work for now.


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

Reply via email to