Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
475
Set page index and current row in backing bean
posted

Hi,

 

In the following code:

GridView gridView;

...

gridView.SetPageIndex(2);

gridView.setPageSize(10);

...

I'm trying to set the current page to 2 (6 pages total) from the backing bean.  The problem is that the .SetpageIndex(2) function doesn't do anything, the grid is always shown with 0 page index. .SetPageSize() function does take affect. What else I need to do? 

Also, how to you set the current row? Say row 2 is the current.

 

thanks,

Yan

  • 210
    posted

    Hello,

    I hope this will helps you much, me too got the same situation, but i tried it a lot and finally got the solution like the code given below,

    You need to write an action class, in this action class you need to get the Bean object from the FacesContext by passing Scope and bean name, after you got the bean object then do the following

    int pageIndex = workItemsBean.getPageIndex();
                workItemsBean.getGrid().setPageIndex(pageIndex);
                workItemsBean.getGrid().dataBind();

    and then forward the control to your current JSF page.

    so for every action or click in a grid, the action class gets executed and sets the current page like what you selected as page 2.

     

  • 10
    Suggested Answer
    posted

    I had to submit a support request to Infragistics about the pageIndex and they gave me the solution.  I'm posting it here so that if anyone else is stuck they can figure it out too.

    If you've set the pageSize attribute on the GridView as an attribute in the JSP page, then SetPageIndex() does not work properly.  You have to take pageSize off of the JSP, and then use setPageSize() and setPageIndex() consecutively in the backing bean.

    If you are setting the pageSize in both the JSP and the backing bean, it doesn't work.  Just do it in the backing bean.  I'd suggest also doing it in that order... setpagesize first, setpageindex second.

    Not sure about the current row, but the above issue should solve your pageIndex woes.

  • 10
    posted

    I'm having the same problem.  Has anyone figured this out?