This is by design, SimplePager ensures you always view a whole page.
There are lots of posts about this "issue" with earlier versions of
GWT on the internet.
Here's an example of a simple pager extension that does what you
need:-
/**
* A custom Pager that maintains a set page size and displays page
numbers and
* total pages more elegantly. SimplePager will ensure <code>pageSize</
code>
* rows are always rendered even if the "last" page has less than
* <code>pageSize</code> rows remain.
*/
public class GuvnorSimplePager extends SimplePager {
//Page size is normally derieved from the visibleRange
private int pageSize = 10;
@Override
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
super.setPageSize( pageSize );
}
// We want pageSize to remain constant
@Override
public int getPageSize() {
return pageSize;
}
// Page forward by an exact size rather than the number of visible
// rows as is in the norm in the underlying implementation
@Override
public void nextPage() {
if ( getDisplay() != null ) {
Range range = getDisplay().getVisibleRange();
setPageStart( range.getStart()
+ getPageSize() );
}
}
// Page back by an exact size rather than the number of visible
rows
// as is in the norm in the underlying implementation
@Override
public void previousPage() {
if ( getDisplay() != null ) {
Range range = getDisplay().getVisibleRange();
setPageStart( range.getStart()
- getPageSize() );
}
}
// Override so the last page is shown with a number of rows less
// than the pageSize rather than always showing the pageSize
number
// of rows and possibly repeating rows on the last and penultimate
// page
@Override
public void setPageStart(int index) {
if ( getDisplay() != null ) {
Range range = getDisplay().getVisibleRange();
int displayPageSize = getPageSize();
if ( isRangeLimited()
&& getDisplay().isRowCountExact() ) {
displayPageSize = Math.min( getPageSize(),
getDisplay().getRowCount()
- index );
}
index = Math.max( 0,
index );
if ( index != range.getStart() ) {
getDisplay().setVisibleRange( index,
displayPageSize );
}
}
}
// Override to display "0 of 0" when there are no records
(otherwise
// you get "1-1 of 0") and "1 of 1" when there is only one record
// (otherwise you get "1-1 of 1"). Not internationalised (but
// neither is SimplePager)
protected String createText() {
NumberFormat formatter = NumberFormat.getFormat( "#,###" );
HasRows display = getDisplay();
Range range = display.getVisibleRange();
int pageStart = range.getStart() + 1;
int pageSize = range.getLength();
int dataSize = display.getRowCount();
int endIndex = Math.min( dataSize,
pageStart
+ pageSize
- 1 );
endIndex = Math.max( pageStart,
endIndex );
boolean exact = display.isRowCountExact();
if ( dataSize == 0 ) {
return "0 of 0";
} else if ( pageStart == endIndex ) {
return formatter.format( pageStart )
+ " of "
+ formatter.format( dataSize );
}
return formatter.format( pageStart )
+ "-"
+ formatter.format( endIndex )
+ (exact ? " of " : " of over ")
+ formatter.format( dataSize );
}
}
Cheers,
Mike
On Apr 6, 8:31 am, bond <[email protected]> wrote:
> Hello guys,
> I'm using CellTable on my project.
> If the page size is 10 and I've 15 rows, Cell table display on the
> first page results from 1-10, when I turn page it displays result from
> 5-15.
> Is possibile change this behaviuor displaying on the first page
> results from 1-10 and on the second page results from 10-15?
>
> Thanks
>
> Cheers
>
> Daniele
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.