← Back to team overview

dhis2-devs team mailing list archive

Re: Pagination patch

 

On Tue, Mar 9, 2010 at 8:32 AM, Murodullo Latifov <murodlatifov@xxxxxxxxx>wrote:

> Hi all,
>
> I created patch for pagination for Dataelement listing for truck head
> (1586) and send it via: bzr send -o pagination.patch. It did go and I don't
> know where did it actually go. Please check if it is there.
>
> regards,
> murod
>
>
Hi ,

I developed a brand new paging feature for patient list. Please see the
screen shot

[image:
?ui=2&view=att&th=12741d645fd0ad56&attid=0.1&disp=attd&realattid=ii_12741d645fd0ad56&zw]



Here I have many features for user :

   - On the right , you can see a paging traveling links, I hard coded to
   show maximum 5 pages, so if you are in page 4th and there are 8 pages, then
   list of pages is : 2,3,4,5,6
   - On left side, there are two function :
   - User can change the side of page, default size can be set it the action
      class, or in action config in struts.xml. After changing the page size,
      start page will be 1.
      - Jump to page is a very useful feature I think, when there are many
      pages and you just don't want to click so many times on the
traveling links.

All input fields will be effected by onchange event.

To implement this, I created  a PagingUtil class, here is the code on the
action class


            pagingUtil = new PagingUtil(
RequestUtil.getCurrentLink(ServletActionContext.getRequest()), pageSize ==
null ? defaultPageSize : pageSize );

            pagingUtil.setCurrentPage( currentPage == null ? 0 : currentPage
);

            total = patientService.countGetPatientsByOrgUnit(
organisationUnit );

            pagingUtil.setTotal( total );

            patients = patientService.getPatientsByOrgUnit( organisationUnit
, pagingUtil.getStartPos(), pagingUtil.getPageSize() );

The constructor of the pagingUtil has two params:

   1. BaseLink : this should be the current link of the request, include all
   param, so if there is a searchText, I will add that searchText param to this
   baseLink. Later, I use this link to redirect user, just only change the
   pageSize and currentPage param.
   2. PageSize.

the pagingUtil object will be sent to .vm file

On .vm file, implement this is easy :-)

       <div class="paging-container">
            <div class="paging-center">
                #parse( "/dhis-web-maintenance-patient/paging.vm" )
            </div>
        </div>
You just need to put this div to the end of the list.
I put everything in the paging.vm , so you just have to parse it . Actually
I tried to use #macro... but don't know why velocity can  not identify the
#macro when I put it in another file and use #parse function to include it
...

So , the dependencies are :  RequestUtil.class, PagingUtil.class , paging.vm
, paging.css.

All the codes are commited , you can check it out in patient module. I have
just implemented this for SearchPatientAction.class , and only for list all
patient case. ( listAll = TRUE )

Regards,

-- 
Viet Nguyen

JPEG image


Follow ups

References