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

Parents
No Data
Reply
  • 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.

     

Children
No Data