gwtgwt-2.4gwt-widgets

How to remove "no data" labels from empty nodes in GWT?


I have a widget that inherits from CellTree. If the node not have the child elements, this node can be opened and shows "no data" label.

I'd like to see nodes without child's displayed as empty.

That's how I fill the tree. My DictionaryTreeDataProvider class (relevant part):

public class DictionaryTreeDataProvider extends ListDataProvider<MValue> {
    private final DictionariesServiceAsync service = GWT.create(DictionariesService.class);

    ...    

    @Override
    public void onRangeChanged(HasData<MValue> result) {
        service.queryDictionaryValues(range, query, new AsyncCallback<SubsetResult<MValue>>() {
            @Override
            public void onFailure(Throwable t) {
            }

            @Override
            public void onSuccess(SubsetResult<MValue> result) {
                getList().clear();
                for (MValue value : result.items) {
                    getList().add(value);
                }
            }
        });
    }
}

On the server side I make EJB call which fills SubsetResult. I found that this problem fixed in version of GWT-2.5.0-rc2 (see https://groups.google.com/forum/#!topic/google-web-toolkit/d-rFUmyHTT4).


Now everything is OK, thanks to @moutellou. I did as he suggested:

...
@Override
public void onSuccess(SubsetResult<MValue> result) {
    if (result.length == 0) {
        updateRowCount(-1, true);
        return;
    } else {
        for (MValue value : result.items) {
            // some checks here
            getList().add(value);
        }
    }
}
...

Solution

  • This is how I removed the no data label in my DataProvider

     //Fetch children
      int size = children.size();
      if (size == 0) {
         updateRowCount(-1, true); //Method called on AsyncDataProvider 
         return;
      }