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
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:
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 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:
Clients client = (Clients) data.get(i);
}
and display the values
msg = "Clients on page: " + str;
Thanks!
-- Bozhidar
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();