Oh, yes and...

response.render(new OnDomReadyHeaderItem("$('#" + pageNumberTextFieldId + "').keydown(function(event){if (event.which == 13){event.preventDefault();$(this).blur();}});")); response.render(new OnDomReadyHeaderItem("$('#" + pageNumberTextFieldId + "').focus(function(){$(this).select();});"));

in renderHead()

Cheers,
Jesse

On 27/06/2014 14:06, Jesse Long wrote:
Hi K,

I use this:


                            <div class="btn-group">
<a wicket:id="firstPageLink" class="btn btn-default"><span class="glyphicon glyphicon-fast-backward"></span></a> <a wicket:id="previousPageLink" class="btn btn-default"><span class="glyphicon glyphicon-backward"></span></a>
                            </div>
Page <input type="text" wicket:id="pageNumberInput" style="margin: 0px; width: 45px; text-align: right; padding: 0px 4px; display: inline-block;" class="form-control"/>
                            of <span wicket:id="numberOfPages"></span>
                            <div class="btn-group">
<a wicket:id="nextPageLink" class="btn btn-default"><span class="glyphicon glyphicon-forward"></span></a> <a wicket:id="lastPageLink" class="btn btn-default"><span class="glyphicon glyphicon-fast-forward"></span></a>
                            </div>




final TextField<Long> pageNumberTextField = new TextField<Long>("pageNumberInput", new IModel<Long>()
        {
            @Override
            public Long getObject()
            {
                return dataTable.getCurrentPage() + 1;
            }

            @Override
            public void setObject(Long object)
            {
                if (object != null){
                    long v = object - 1;
                    if (v > dataTable.getPageCount() - 1){
                        v = dataTable.getPageCount() - 1;
                    }else if (v < 0){
                        v = 0;
                    }
                    setCurrentPage(v);
                }
            }

            @Override
            public void detach()
            {
            }
        }, Long.class)
        {
            @Override
            protected void onConfigure()
            {
                super.onConfigure();

                clearInput();
            }
        };

pageNumberTextField.add(new AjaxFormComponentUpdatingBehavior("change")
        {
            @Override
protected void onError(AjaxRequestTarget target, RuntimeException e)
            {
                pageNumberTextField.clearInput();
                target.add(pageNumberTextField);
                target.focusComponent(pageNumberTextField);
            }

            @Override
            protected void onUpdate(AjaxRequestTarget target)
            {
target.add(container); // container including navigation as well as data table
                target.focusComponent(pageNumberTextField);
            }
        });

        pageNumberTextField.setOutputMarkupId(true);
        add(pageNumberTextField);

        add(new AjaxFallbackLink<Void>("firstPageLink")
        {
            @Override
            public void onClick(AjaxRequestTarget target)
            {
                setCurrentPage(0);
                if (target != null){
target.add(container); // container including nav and data table
                }
            }

            @Override
            protected void onConfigure()
            {
                super.onConfigure();

                setEnabled(dataTable.getCurrentPage() > 0);
            }
        });

        add(new AjaxFallbackLink<Void>("previousPageLink")
        {
            @Override
            public void onClick(AjaxRequestTarget target)
            {
                long currentPage = dataTable.getCurrentPage();

                if (currentPage > 0){
                    setCurrentPage(currentPage - 1);
                }

                if (target != null){
target.add(container); // container including nav and data table
                }
            }

            @Override
            protected void onConfigure()
            {
                super.onConfigure();

                setEnabled(dataTable.getCurrentPage() > 0);
            }
        });

        add(new AjaxFallbackLink<Void>("nextPageLink")
        {
            @Override
            public void onClick(AjaxRequestTarget target)
            {
                long currentPage = dataTable.getCurrentPage();

                if (currentPage < dataTable.getPageCount() - 1){
                    setCurrentPage(currentPage + 1);
                }

                if (target != null){
target.add(container); // container including nav and data table
                }
            }

            @Override
            protected void onConfigure()
            {
                super.onConfigure();

setEnabled(dataTable.getCurrentPage() < dataTable.getPageCount() - 1);
            }
        });

        add(new AjaxFallbackLink<Void>("lastPageLink")
        {
            @Override
            public void onClick(AjaxRequestTarget target)
            {
                setCurrentPage(dataTable.getPageCount() - 1);

                if (target != null){
target.add(container); // container including nav and data table
                }
            }

            @Override
            protected void onConfigure()
            {
                super.onConfigure();

setEnabled(dataTable.getCurrentPage() < dataTable.getPageCount() - 1);
            }
        });

        add(new Label("numberOfPages", new AbstractReadOnlyModel<Long>()
        {
            @Override
            public Long getObject()
            {
                return dataTable.getPageCount();
            }
        });


This is bootstrap 3 pretty much does what you are asking. I dont implement this as a data table toolbar, but rather directly below the data table (my data table is wrapped in overflow-x: auto).

Cheers,
Jesse



On 27/06/2014 12:58, K wrote:
Hey there

  i have been trying to trying to implement something like

<< <  (textbox)  of (totalnumberofpages) > >>

any suggestions on this

Thanks in advance...

-----

K
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Pagination-in-wicket-tp1878842p4666398.html
Sent from the Users forum mailing list archive at Nabble.com.

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




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




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

Reply via email to