Infragistics Home

Infragistics Forums

Infragistics community online discussions.
Welcome to Infragistics Forums Sign in | FAQ
in Search

Getting all RowItem for currently selected page

Last post 07-30-2008 7:05 by [Infragistics] Bozhidar Dedov. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 07-24-2008 0:47

    Getting all RowItem for currently selected page

    Hi,

    i have added pageChangeListener to GridView, i want to get all RowItems for the currently selected page,

    getRows() method giving previous page RowItems, can you people give me any suggestion,

    any help will be appreciated.

     

    Thanks

    Dayananda B V 

    Filed under:
    • Post Points: 20
  • 07-24-2008 7:43 In reply to

    Re: Getting all RowItem for currently selected page

    Hello, Dayananda B V!

    Unfortunatelly you canot use getRows() for that aim. But there is a trick, you can apply for your purpose. In the event handler you can do the following:

    HtmlGridView grid = (HtmlGridView) e.getComponent();

    List data = (List) grid.getDataSource().getWrappedData();

    where data  is the actual underlying data source (not limited by page size). Then you have the page size and the new page index, accordingly:

    int pageSize = grid.getPageSize();

    int newIndex = e.getNewPageIndex();

     By having the whole data list for the data source, the new index and the page size, you can now estimate the list of rows for the current page:

    int startIndex = newIndex * pageSize;

    int endIndex = startIndex + pageSize - 1;

     Now you can iterate through the list containing all rows (data), starting from the startIndex and ending with the endIndex and get the property you need, in my example:

    for(int i = startIndex; i <= endIndex; i++){

    Clients client = (Clients) data.get(i);

    str += ((Clients) data.get(i)).getId() +
    "; ";

    }

    and display the values

    msg = "Clients on page: " + str;

    Thanks!

    -- Bozhidar

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    • Post Points: 20
  • 07-24-2008 8:38 In reply to

    Re: Getting all RowItem for currently selected page

     Hi Bozhidar,

    Thanks you very much for qucik replay, the solution you given is for getting the data, but i want RowItem itself 

     for example look at this code, you can get a idea what i am looking for.

           public void onPageSelectUnits(PageChangeEvent evt){
            
            try{ 

                Iterator currentPageRowItems = getUnitsGrid().getRows().iterator(); // here i am getting previous page RowItems

                while (currentPageRowItems.hasNext()) {
                    RowItem rowItem = (RowItem) currentPageRowItems.next();
                    {
                        rowItem.setSelected(true);
                    }
                }

        }catch(Exception e){

        e.printStackTrace(); 

    }

     

    Thanks

    Dayananda B V 

    • Post Points: 20
  • 07-25-2008 4:41 In reply to

    Re: Getting all RowItem for currently selected page

    Answer

    Hello, Dayananda B V!

    Now I understand what you want to do but I'm affraid that currently there is no way to get the row items on the current page. You can submit a feature request to the support group http://devcenter.infragistics.com/Protected/RequestFeature.aspx indicating that your request refers to NetAdvanateg for JSF. So you can contribute to making our product always better.

    Thanks!

    --Bozhidar

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    • Post Points: 20
  • 07-25-2008 7:03 In reply to

    Re: Getting all RowItem for currently selected page

    can you tell me any workaround or suggestion for the same? 

    • Post Points: 20
  • 07-25-2008 7:13 In reply to

    Re: Getting all RowItem for currently selected page

    Hi,

    as far as I understand your purpose, I think you could add a property to your bean that you use as a flag.

    --Bozhidar

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    • Post Points: 20
  • 07-25-2008 8:11 In reply to

    Re: Getting all RowItem for currently selected page

    Hi,

    thanks for your replay,

    i did not understand your suggestion, could elaborate little bit more, how it helps just by adding flag, and i have tried firing dummy events too, but it is not helping me. And as for i know, i have not found any facility to get all page RowItems in GridView. Can you tell me is there any way to get all the RowItems in a GridView?.

     

    thanks inadvance

    Dayananda B V 

     

    • Post Points: 20
  • 07-28-2008 2:00 In reply to

    Re: Getting all RowItem for currently selected page

    Hi, Dayananda B V!

    There is no way to get all RowItems from GridView yet. You can get the data source and so my suggestion was to add a boolean property to the bean representing the data in the rows and to set it to true instead of rowItem.setSelected(true); in your action listener. I hope this helps.

    Thanks!

    -- Bozhidar

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    • Post Points: 20
  • 07-28-2008 2:12 In reply to

    Re: Getting all RowItem for currently selected page

    Hi Bozhidar,

    Thank your very much for your prompt replay, it's ok to set boolean variable true, my problem is have a check box in GridView which is automaticaly added by this code

    "<ig:columnSelectRow showSelectAll="true"/>,

    so actually i have to set check box as a selected depedning on some condition. is this possible? is there any way? if i am able to get all RowItems from GridView for the currently selected page than no problem for me, but as you told there is no such facility. And you are suggesting use some boolena variable to do. my question is who can set the check box as selected. using boolean variable, is this possible.

     thanks

    Dayananda B V 

     

     

     

    • Post Points: 20
  • 07-28-2008 4:53 In reply to

    Re: Getting all RowItem for currently selected page

    Answer

    Hi, Dayananda B V!

    Try to data bind your grid after getting it in the action listener, e.g.:

    grid = (HtmlGridView) e.getSource();

    grid.dataBind();

    and then use getRows();

    It will now return the list of the currently displayed Row Items.

    I hope this will work.

    -- Bozhidar

     

     

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    • Post Points: 44
  • 07-30-2008 6:57 In reply to

    Re: Getting all RowItem for currently selected page

     Hi Bozhidar,

     

    thanks your excellent support, the suggestion you given  i.e. dataBind works great, thanks once again

    Dayananda B V 

     

    • Post Points: 20
  • 07-30-2008 7:05 In reply to

    Re: Getting all RowItem for currently selected page

    Glad for being useful!

    Regards!

    --Bozhidar

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    Filed under:
    • Post Points: 5
Page 1 of 1 (12 items)
Powered by Community Server (Commercial Edition), by Telligent Systems