Re: InMethod Grid: resizing rowcount

2010-03-16 Thread Erik van Oosten

I can confirm this. It took me a few days of debugging before I found out :(

Another solution is to just replace the inmethod grid with a freshly 
created instance after data changes. You can share the DataSource, and 
you may have to copy over the set of selected items.


Regards,
   Erik.


Pointbreak wrote:

...
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.
  


--
Sent from my SMTP compliant software
Erik van Oosten
http://day-to-day-stuff.blogspot.com/



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



Re: InMethod Grid: resizing rowcount

2010-03-16 Thread Pointbreak
On Mon, 15 Mar 2010 16:06 +0100, "Thierry Peng"  wrote:
> Pointbreak schrieb:
> > On Mon, 15 Mar 2010 15:06 +0100, "Thierry Peng"  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 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



Re: InMethod Grid: resizing rowcount

2010-03-15 Thread Thierry Peng

Pointbreak schrieb:

On Mon, 15 Mar 2010 15:06 +0100, "Thierry Peng"  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 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


--
Thierry Peng
  __  _
 / / /   / / / / /   GLUE Software Engineering AG
/ / __/ /   / / / / __/ Zieglerstr. 34, 3007 Bern,  Switzerland
/ /_/ / /___/ /_/ / /___Phone: +41-(0)31/385 30 34Fax: 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



Re: InMethod Grid: resizing rowcount

2010-03-15 Thread Pointbreak
On Mon, 15 Mar 2010 15:06 +0100, "Thierry Peng"  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 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



Re: InMethod Grid: resizing rowcount

2010-03-15 Thread Thierry Peng

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 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 34Fax: 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



InMethod Grid: resizing rowcount

2010-03-15 Thread Pointbreak
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