You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sam Zilverberg <sa...@gmail.com> on 2010/06/24 11:06:11 UTC

inmethod custom PagingToolbar with dropdownchoice for setting rows not working correctly

Hi,
First I'd like to say that inmethod grid is great, I've been using inmethod
grid for a while and have been very satisfied with it!
Major kudos to the creator/s!!

The problem:
I have a simple drop down choice to change the rowsPerPage:

DropDownChoice<Integer> ddc = new DropDownChoice<Integer>("showPerPage", new
PropertyModel<Integer>(
                MyPagingToolbar.this, "ROWS_NUM"), Arrays.asList(20, 50,
100)) {
            private static final long serialVersionUID =
-8768375316550684005L;

            @Override
            protected boolean wantOnSelectionChangedNotifications() {
                return true;
            }

            @Override
            protected void onSelectionChanged(Integer newSelection) {
                getDataGrid().setRowsPerPage(newSelection);
            }

        };
add(ddc);

This DDC works fine when it is located outside of the grid, just above it
markup wise.
I wanted to put this DDC  inside the paging toolbar so it will look better.
I've created a MyPagingToolbar with the same code/markup as the
PagingToolbar and added this component
to the constructor and markup.

The DDC doesn't work as expected this way, it is always one step behind of
the grid.
If I choose 50 rows per page, the grid reloads and only then the DDC model
is changed to 50.
The next time I choose 20 again, the grid loads 50 per page (the last ddc
model) and only then
changed the ddc model to 20...

Anyone has any idea why this would happen?

The only difference i find so far between the 2 methods - outside the
grid/inside the toolbar - is that
when the ddc is inside the toolbar it is also inside a form - a filter form
i use along with the grid because i've
created a filter toolbar

-Sam.

Re: inmethod custom PagingToolbar with dropdownchoice for setting rows not working correctly

Posted by nino martinez wael <ni...@gmail.com>.
I've had some strange things to, as the "delay" in choice you mentioned.
However in my case I had two grids(master/detail) on the same page, my
workaround was to create a new instance of the failing grid.. It had
something todo with a problem with datasources but I dont remember the
details now.

2010/6/24 Sam Zilverberg <sa...@gmail.com>

> Hi,
> First I'd like to say that inmethod grid is great, I've been using inmethod
> grid for a while and have been very satisfied with it!
> Major kudos to the creator/s!!
>
> The problem:
> I have a simple drop down choice to change the rowsPerPage:
>
> DropDownChoice<Integer> ddc = new DropDownChoice<Integer>("showPerPage",
> new
> PropertyModel<Integer>(
>                MyPagingToolbar.this, "ROWS_NUM"), Arrays.asList(20, 50,
> 100)) {
>            private static final long serialVersionUID =
> -8768375316550684005L;
>
>            @Override
>            protected boolean wantOnSelectionChangedNotifications() {
>                return true;
>            }
>
>            @Override
>            protected void onSelectionChanged(Integer newSelection) {
>                getDataGrid().setRowsPerPage(newSelection);
>            }
>
>        };
> add(ddc);
>
> This DDC works fine when it is located outside of the grid, just above it
> markup wise.
> I wanted to put this DDC  inside the paging toolbar so it will look better.
> I've created a MyPagingToolbar with the same code/markup as the
> PagingToolbar and added this component
> to the constructor and markup.
>
> The DDC doesn't work as expected this way, it is always one step behind of
> the grid.
> If I choose 50 rows per page, the grid reloads and only then the DDC model
> is changed to 50.
> The next time I choose 20 again, the grid loads 50 per page (the last ddc
> model) and only then
> changed the ddc model to 20...
>
> Anyone has any idea why this would happen?
>
> The only difference i find so far between the 2 methods - outside the
> grid/inside the toolbar - is that
> when the ddc is inside the toolbar it is also inside a form - a filter form
> i use along with the grid because i've
> created a filter toolbar
>
> -Sam.
>

Re: inmethod custom PagingToolbar with dropdownchoice for setting rows not working correctly

Posted by Sam Zilverberg <sa...@gmail.com>.
I've remove the filter-form and toolbar to see if they affect this
situation, sadly they dont.

When the rows-per-page DDC is outside the toolbar (and outside the grid
markup) choosing a value will correctly change the DDC's model object and
then the grid is rendered again using the correct DDC integer value.

When this DDC is inside the toolbar the grid is first rendered and only then
the DDC's model object is updated - causing a "delay" between the DDC's
model object and the grids rows per page value.

any ideas? or do I have to create a new grid instance as nino suggests?

Re: inmethod custom PagingToolbar with dropdownchoice for setting rows not working correctly

Posted by Sam Zilverberg <sa...@gmail.com>.
vov: adding this behavior doesn't solve the problem. with this behavior the
ddc never reaches the "getDataGrid().setRowsPerPage(newSelection);" line in
the code.

Re: inmethod custom PagingToolbar with dropdownchoice for setting rows not working correctly

Posted by vov <vo...@mail.ru>.
Try to use:

yourDDC.add(new AjaxFormComponentUpdatingBehavior("onchange")
    {
      @Override
      protected void onUpdate(AjaxRequestTarget target)
      {
          target.addComponent(yourGridComponent); //like MyGrid.this
      }
    });
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/inmethod-custom-PagingToolbar-with-dropdownchoice-for-setting-rows-not-working-correctly-tp2266659p2268034.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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