incubator's PagingScrollTable(pagination+Sorting)

28 views
Skip to first unread message

shloka

unread,
Nov 2, 2009, 11:35:41 PM11/2/09
to Google Web Toolkit
Hi All,
I am trying to implement pagination and sorting using the Incubator's
paging scroll table .Could do pagination but Sorting is not happening.
Please pool in some ideas to solve this.Any guidence is highly
appreciated.,,,,
Thanks in Advance.

Davis Ford

unread,
Nov 3, 2009, 10:36:39 AM11/3/09
to google-we...@googlegroups.com
Sorting does seem to work out of the box.  I ended up building my own comparators.

Here's an example of what I did.  I was going to write up a longer blog entry on this -- just haven't had time.

Let's say I have a simple object like this for my RowValue:

public class Person {
   private final String first; 
   private final String last;
   public Person(String first, String last) { first = first; last = last; }
   public String getFirst() { return first; }
   public String getLast() { return last; }
}

So, I have to define my table model for Person =>

private final classs DataSourceTableModel extends MutableTableModel<Person> {

    private List<Person> list = new ArrayList<Person>();

    public void setData(List<Person> list) { this.list = list; }

    public void requestRows(final Request request, TableModel.Callback<Person> callback) {
            callback.onRowsReady(request, new Response<Person>() {
                @Override
                public Iterator<Person> getRowValues() {
                    int col = request.getColumnSortList().getPrimaryColumn();
                    boolean ascending = request.getColumnSortList().isPrimaryAscending();
                  
                    /* col tells you which column the user clicked and ascending indicates whether to sort up/down */
                    /* i wrote my own Sorter class that knows how to sort a collection of my own RowValue T here */
                    /* return the iterator of your sorted collection */
               }};
     }
}

There's a bit more to it, but I found that PagingScrollTable does not sort by itself -- never worked for me.  I filed a bug on it.  Thus, I do the sorting myself, and it works well. 

Hope that helps,
Davis
--
Zeno Consulting, Inc.
home: http://www.zenoconsulting.biz
blog: http://zenoconsulting.wikidot.com
p: 248.894.4922
f: 313.884.2977

shloka

unread,
Nov 4, 2009, 2:40:25 AM11/4/09
to Google Web Toolkit
Thanks Davis !

Yes,I saw the Bug u have reported.


I tried with gwtlib.jar and sample code given for this in the link
http://code.google.com/p/gwtlib/
They use PagingTable and write the comparator code for sorting...
The approach is same as you have suggested...

So now i have to decide weather to go for PagingScrollTable of
incubator or PagingTable of gwtlib :)


Thanks!!

Open eSignForms

unread,
Nov 12, 2009, 5:11:16 PM11/12/09
to Google Web Toolkit
What are people's impressions of these widgets in production use? It
seems I've read a lot of negative stuff about PagingScrollTable, and
it's clear that sorting does not work, which is funny when you run
their demo since it touts sorting, yet not a single column sorts
correctly.

I've not had a chance to play with gwtlib's PagingTable, but am a bit
concerned the version release is 0.1.6, which sounds far from being
production ready, and the last update was May 2, so clearly there's no
real work effort moving it forward. So, is it really 0.1.6, or does
it work well enough that it's really 1.0 at least?

It is surprising that such tables are not part of GWT core yet. This
is one of the most common widgets needed for most data-centric apps.

Davis Ford

unread,
Nov 12, 2009, 8:26:39 PM11/12/09
to google-we...@googlegroups.com
I'm going to production with PagingScrollTable from incubator.  I wrote some unit tests around it and have had no issues with it, but more importantly, I've had this app running live for several months in a dev/test environment, and it has worked flawlessly across browsers (IE 6, 7, 8, Firefox 3.*, Chrome).

I'm using it to present the results of a search page.  You search for, let's just say a person by last name, GWT-RPC fetches the results from Oracle and returns an ArrayList, and I shove it into the PagingScrollTable.  We've been hammering it pretty good, and so far, it has worked great.

Regards,
Davis

--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=.


Yozons Support on Gmail

unread,
Nov 12, 2009, 9:24:50 PM11/12/09
to google-we...@googlegroups.com
Thanks.  I'll spend more time to investigate this option, then, since it likely has improved since a lot of the earlier gripes.  More examples and better documentation are always the answer, but I know how hard it is to have it all :)

jay

unread,
Nov 13, 2009, 11:08:16 AM11/13/09
to Google Web Toolkit
We've been shipping our product with PagingScrollTable for the past 4
months. We've been very happy with the widget. We've made a lot of
changes around it to get more functionality and (in our opinion)
better styling.

We've not heard any complaints from our users about performance or
anything else (at least, nothing that wasn't *our* bug).

jay

kavitha d

unread,
Nov 13, 2009, 11:10:47 AM11/13/09
to google-we...@googlegroups.com

Norman Maurer

unread,
Nov 13, 2009, 12:05:58 PM11/13/09
to google-we...@googlegroups.com
We using the Table in hupa ( http://James.Apache.org/hupa) . It Works
very well so far . We extend it to support drag-and-drop and
refetching data After deletion to fill the page.

Bye
Norman
2009/11/13, kavitha d <kavim...@gmail.com>:
>> google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
>> .

Davis Ford

unread,
Nov 15, 2009, 9:27:11 PM11/15/09
to google-we...@googlegroups.com
Hi, here's a blog post I made that shows how I'm using the widget.  It may help if you are still looking for a solution.


Regards,
Davis

--~--~---------~--~----~------------~-------~--~----~

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Dazza

unread,
Nov 16, 2009, 3:02:32 PM11/16/09
to Google Web Toolkit
On Nov 16, 3:27 pm, Davis Ford <davisf...@zenoconsulting.biz> wrote:
> Hi, here's a blog post I made that shows how I'm using the widget.  It may
> help if you are still looking for a solution.
>
> http://zenoconsulting.wikidot.com/blog:17
>
> <http://zenoconsulting.wikidot.com/blog:17>Regards,
> Davis
>

Very nice article. Have you tried adding fixed columns to
PagingScrollTable?

Davis Ford

unread,
Nov 16, 2009, 3:08:35 PM11/16/09
to google-we...@googlegroups.com
Yes, I have done this in some cases.  You can do this with the methods from AbstractColumnDefinition

setMinimumColumnWidth()
setMaximumColumnWidth()

It seems to work ok.  If your columns span past the visible area, you end up getting a horizontal scrollbar which is expected.  Also you can force the width to whatever the maximum entry width is if you setTruncatable(false)

--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=.


shloka

unread,
Nov 17, 2009, 1:28:24 AM11/17/09
to Google Web Toolkit
Davis, thanks for the post ...
In your example Are you using the pagination also?
How do you maintain sorted data between the pages??
I have implemented sorting almost like what you have done....
but i am facing problem in maintaining the sorted data with the
pagination.
say i have 10 rows and i make it 5 rows per page.Hence i get 2 pages
now the first page is sorted and fine .when i click the button to go
to next page the control goes to the below function in the
DataSourceTableModel
public void requestRows(final Request request,
final Callback<Student> callback) {
// here we have method to create the new data.. how do we stop this?
since i have 5 more rows of old sorted data yet to be rendered
or
if we have hard coded array list data it will again fetch the data as
per page size ie first 5 data but i need data from 6 to 10 .
}

pls share u r thoughts on this.....

Thanks
Chythanya
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsubs­cr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en
> > -~----------~----~----~----~------~----~------~--~---
>
> --
> Zeno Consulting, Inc.
> home:http://www.zenoconsulting.biz
> blog:http://zenoconsulting.wikidot.com
> p: 248.894.4922
> f: 313.884.2977- Hide quoted text -
>
> - Show quoted text -

Davis Ford

unread,
Nov 17, 2009, 7:31:28 AM11/17/09
to google-we...@googlegroups.com
Hi Chythanya -- take a look at the Live Demo on that page.  I do have paging in place with the PagingOptions, and sorting works just fine with it.

Regards,
Davis

--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=.


Yozons Support on Gmail

unread,
Nov 17, 2009, 7:17:45 PM11/17/09
to google-we...@googlegroups.com
I think the example you have also loads all rows and doesn't use "page fetching" to load only the first page, waiting until they click next page to actually retrieve additional rows.  It seems the example gets all rows, so the sorting is all local and works on all data, no additional fetching takes place.

Also, I noted in your onRowSelection() callback, you use:

                int rowIdx = set.iterator().next().getRowIndex();
                String id = pagingScrollTable.getDataTable().getHTML(rowIdx, 0);
                Message m = tableModel.getMessageById(Long.parseLong(id));

I wondered why you took your ArrayList and then created the HashMap based on ID, and it seems use use this scheme to get the selected row object.  But couldn't you just use the paging scroll table's method to get the selected object directly:

                int rowIdx = set.iterator().next().getRowIndex();
                Message m = pagingScrollTable.geRowValue(rowIdx);
 
Or is there some other reason for your retrieval method?  Thanks again for your code example.  I'm still working through and have basic table functionality working now myself.

Davis Ford

unread,
Nov 17, 2009, 8:48:14 PM11/17/09
to google-we...@googlegroups.com
Hi, you are correct, I don't do client/server pagination.  I did not want to do this.  It adds another layer of complexity that I didn't want.  I happen to know that my app will only return results in the hundreds to lower thousands range, and I found a perfect match between this and the PagingScrollTable loading it all in memory.  If you try the live demo -- even 10,000 rows loads fast (~1.5 s).  Increase it ten-fold though, and that's where the breaking point seems to be.  I'm fairly certain that this application won't ever need client/server pagination, but if some day it does -- it isn't a huge tear up.  It is a simple design tradeoff -- following the YAGNI principle here.

It just so happened that my GWT-RPC service returned an ArrayList<Model> -- so, that ended up being the public input to this widget.  But, as you saw, I throw it away and index it by id in the map.  You don't have to do this, obviously.  It provides an easy way for me to retrieve the original object.  I did not try pagingScrollTable.geRowValue(rowIdx); -- why? probably b/c I didn't see the API.  Maybe it works, and the map is unnecessary.  I'll try it out later -- thanks for pointing it out!

Regards,
Davis

--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=.
Reply all
Reply to author
Forward
0 new messages