Celltable loading state

5,208 views
Skip to first unread message

Deepak Singh

unread,
Feb 10, 2011, 2:05:36 PM2/10/11
to google-we...@googlegroups.com
Hi All,

How can we set the loading image to be visible till the cell table loads ?

John LaBanca

unread,
Feb 10, 2011, 2:25:13 PM2/10/11
to google-we...@googlegroups.com
You can specify your own image by extending CellTable.Resources and replacing cellTableLoading().

interface MyResources extends CellTable.Resources {
  @Source("myImage.png");
  ImageResource cellTableLoading();
}


CellTable.Resources res = GWT.create(CellTable.Resources.class);
CellTable table = new CellTable(25, res);


Thanks,
John LaBanca
jlab...@google.com


On Thu, Feb 10, 2011 at 2:05 PM, Deepak Singh <deepaksingh.kr@gmail.com> wrote:
Hi All,

How can we set the loading image to be visible till the cell table loads ?

--
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.

Y2i

unread,
Feb 10, 2011, 2:26:49 PM2/10/11
to google-we...@googlegroups.com
I use setRowCount(0, true).

Y2i

unread,
Feb 10, 2011, 2:29:45 PM2/10/11
to google-we...@googlegroups.com
Oops, sorry, I mis-read the question...

John LaBanca

unread,
Feb 10, 2011, 2:29:00 PM2/10/11
to google-we...@googlegroups.com
My bad, I misunderstood.

table.setVisibleRangeAndClear() will ensure that the loading indicator appears until setRowCount(0, true) or setRowData() are called.

Thanks,
John LaBanca
jlab...@google.com


On Thu, Feb 10, 2011 at 2:26 PM, Y2i <yur...@gmail.com> wrote:
I use setRowCount(0, true).

Craig Day

unread,
Feb 10, 2011, 7:07:56 PM2/10/11
to google-we...@googlegroups.com
Except there is no such method :).  Perhaps you mean something like:

        table.setVisibleRangeAndClearData(table.getVisibleRange(), true);

Cheers
Craig

BST

unread,
Aug 11, 2011, 5:09:11 PM8/11/11
to google-we...@googlegroups.com
Hi John,
 
Is there any way to disable the loading indicator from showing ? I even tried native methods, no luck. I am using a ListDataProvider, when I have data to show I just clear the existing list of the data provider. But problem is first time the image always shows.

One way is to replace the current image with a blank image. But I was hoping for another solution.

David Sanders

unread,
Oct 14, 2011, 7:05:29 AM10/14/11
to google-we...@googlegroups.com
You'd probably need to add a zero-sized array list of data and set what you want to show with table.setEmptyTableWidget()

Magallo

unread,
Mar 1, 2012, 11:44:44 AM3/1/12
to google-we...@googlegroups.com
I am sorry. I found this page surfing the web, I hope this is a good point to ask this.

I have a problem using loading indicators in DataGrid. What is the right way to set to the DataGrid the state of LOADING or LOADED? I didn't find any resource whatsoever anywehere. The support for this is really poor. By the way, whare am I wrong?

I just inizialize my DataGrid using:

myDataGrid.setLoadingIndicator(new Image(/*my ImageResource object*/);

and the during the flow of the program I use:

myDataGrid.fireEvent(new LoadingStateChangeEvent(LoadingState.LOADING));

when I want to put the DataGrid in the 'LOADING' state, i.e. just before making an RCP call, and then:

myDataGrid.fireEvent(new LoadingStateChangeEvent(LoadingState.LOADED));

just after the grid has been populated with data.

This doesn't work.

Please help.

Jens

unread,
May 15, 2012, 9:59:38 AM5/15/12
to google-we...@googlegroups.com
table.setVisibleRangeAndClear() will ensure that the loading indicator appears until setRowCount(0, true) or setRowData() are called.

I am using a CellList and it seems like that AbstractHasData.setVisibleRangeAndClear() does not show the loading indicator if the CellList is empty. Its basically like:

1.) CellList created => shows loading indicator
2.) Server returns 0 records => ListDataProvider is empty => shows empty indicator
3.) Calling list.setVisibleRangeAndClear(list.getVisibleRange(), true) to show loading indicator because I want to reload the list data => no loading indicator, still shows empty indicator while data is loading.
4.) CellList/DataProvider now contains some data and when redoing 3.) the loading indicator appears as expected.

Anyone knows if this is intentional behavior? To me it seems like a bug. Is there any other way to show the loading indicator even if the list is empty?

-- J.

Chris Price

unread,
May 15, 2012, 11:19:59 AM5/15/12
to google-we...@googlegroups.com
I looked into this a little while ago and as far as I could tell using
the ListDataProvider prevents the loading indicator from ever being
shown (long explanation which I never got round to writing up, but if
there's interest I will do). The ListDataProvider is intended to be
used when all of the data is resident in the client, if it isn't then
you should use AsyncDataProvider.
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/UukgWkmauhYJ.

Jens

unread,
May 15, 2012, 12:11:37 PM5/15/12
to google-we...@googlegroups.com
I looked into this a little while ago and as far as I could tell using
the ListDataProvider prevents the loading indicator from ever being
shown (long explanation which I never got round to writing up, but if
there's interest I will do). The ListDataProvider is intended to be
used when all of the data is resident in the client, if it isn't then
you should use AsyncDataProvider.

Even when using an AsyncDataProvider the loading indicator isn't shown when calling list.setVisibleRangeAndClearData(list.getVisibleRange(), true) and the list data is empty at that time. I think its independent of the DataProvider you use. As soon as you have no data in your CellList the loading indicator does not work like expected....well or I have missed something obvious?!

-- J.

Chris Price

unread,
May 15, 2012, 12:20:23 PM5/15/12
to google-we...@googlegroups.com
You need to make sure that the cell-widget thinks the current page
size is non-zero e.g. setRowCount(x) (where x > 0). You're basically
trying to convince this method to enter the LOADING state -

private void updateLoadingState() {
int cacheSize = getVisibleItemCount();
int curPageSize = isRowCountExact() ? getCurrentPageSize() : getPageSize();
if (cacheSize >= curPageSize) {
view.setLoadingState(LoadingState.LOADED);
} else if (cacheSize == 0) {
view.setLoadingState(LoadingState.LOADING);
} else {
view.setLoadingState(LoadingState.PARTIALLY_LOADED);
}
}

The cacheSize is retrieved eventually from the maximum relative index
in the current page (i.e. the first visible item is index 0) that has
had data associated with it plus one (to convert the index to a
count). This is because as data is pushed into each index in the page,
a placeholder data value of null is pushed into any missing indices up
to the current index.

The curPage size is just the size of the current page, either the
specified page size in the last setVisibleRange call, or if the row
count is exact and the last page is being viewed, then row count
modulo page size (i.e. if there aren’t enough items to fill the last
page).
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/305iEPbSaGYJ.

Jens

unread,
May 15, 2012, 12:38:35 PM5/15/12
to google-we...@googlegroups.com
You need to make sure that the cell-widget thinks the current page
size is non-zero e.g. setRowCount(x) (where x > 0). You're basically
trying to convince this method to enter the LOADING state -

  private void updateLoadingState() {
    int cacheSize = getVisibleItemCount();
    int curPageSize = isRowCountExact() ? getCurrentPageSize() : getPageSize();
    if (cacheSize >= curPageSize) {
      view.setLoadingState(LoadingState.LOADED);
    } else if (cacheSize == 0) {
      view.setLoadingState(LoadingState.LOADING);
    } else {
      view.setLoadingState(LoadingState.PARTIALLY_LOADED);
    }
  }

Ok I have now:

list.setVisibleRangeAndClearData(list.getVisibleRange(), true);
list.setRowCount(1);

and it works for empty data in the CellList as well as with data. But to me it seems really "hackish".

-- J. 

Chris Price

unread,
May 15, 2012, 12:48:01 PM5/15/12
to google-we...@googlegroups.com
I suppose it's intended for the situation where you know at least a
rough estimate of the count before requesting the data e.g. paging.
Another example could be passing the category item count down along
with the category name etc. when requesting the category list,
assuming a list of categories is what is swapping out the data in the
table. I agree it struggles in the case of requesting a completely
arbitrary set of data, maybe a method like setRowCountUnknown() would
"clean it up".
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/rjiC8vRwQ3kJ.

Craig Mitchell

unread,
Jan 22, 2013, 1:14:23 AM1/22/13
to google-we...@googlegroups.com
With GWT 2.5, looking into HasDataPresenter.updateLoadingState, I realized I also had to set the page size to see the loading indicator when loading on an empty table.  My my "hack" was:

setRowCount(1);
setPageSize(1);
setVisibleRangeAndClearData(getVisibleRange(), true);

ips

unread,
Mar 6, 2013, 2:40:13 PM3/6/13
to google-we...@googlegroups.com
I am with you that the loading indicator is never displayed when using a ListDataProvider. Using GWT 2.5, I tried all the methods mentioned in this thread, and none of them worked. So I came up with the following hack, which essentially temporarily hijacks the empty table widget for use as a loading indicator...

    // I call this method just prior to starting to async reload my data and update my ListDataProvider
    public void showLoadingIndicator() {
        this.emptyTableWidget = getEmptyTableWidget();
        setEmptyTableWidget(getLoadingIndicator());
        this.listDataProvider.getList().clear();
        this.listDataProvider.flush();
    }

    // I call this method after my I've updated the data in my ListDataProvider
    public void hideLoadingIndicator() {
        setEmptyTableWidget(this.emptyTableWidget);
    }


--Ian


Shakti Singh

unread,
Jul 17, 2020, 6:53:30 AM7/17/20
to GWT Users
            dataGrid.setRowCount(0, false); should do the magic
Reply all
Reply to author
Forward
0 new messages