Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First you should make sure that your RPC returns the appropriate List of hastaGrid objects - and please do capitalize the class name :) I use the <code>AsyncDataProvider</code> model quite a lot with various <code>DataGrid</code> implementations and create an implementing class somewhat like the following: </p> <pre><code>public class MyProvider extends AsyncDataProvider&lt;MyModelObject&gt; implements AsyncCallback&lt;List&lt;MyModelObject&gt;&gt; { static int PAGESIZE = 50; List&lt;MyModelObject&gt; cache = new ArrayList&lt;MyModelObject&gt;(); @Override protected void onRangeChanged(HasData&lt;MyModelObject&gt; display) { final Range range = display.getVisibleRange(); int start = range.getStart(); int end = start + range.getLength(); if (start &gt;= cache.size() - 1) { lastVisible = cache.size() - 1; gwtService.fetchRowsFromDbase(this); return; } List&lt;MyModelObject&gt; dataInRange = cache.isEmpty() ? new ArrayList&lt;MyModelObject&gt;() : cache.subList(start, end &gt;= cache.size() ? (cache.size()) : end); updateRowData(start, dataInRange); } public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } public void onSuccess(List&lt;MyModelObject&gt; result) { if (result.isEmpty()) { //display a warning return; } for (MyModelObject a : result) { if (cache.indexOf(a) == -1) cache.add(a); } updateRowData(cache.indexOf(result.get(0)), result); updateRowCount(cache.size(), result.size() &lt; PAGESIZE); tab.setPageSize(PAGESIZE); tab.setPageStart(lastVisible); MyModelObject last = cache.get(cache.size() - 1); orderOffset = last.getId(); } public List&lt;MyModelObject&gt; getCache() { return cache; } } </code></pre> <p>In your DataGrid initalization code you put:</p> <pre><code>MyProvider pr = new MyProvider(); pr.addDataDisplay(yourDataGrid); </code></pre> <p>This approach works best if you also add a pager, because the dataprovider listens to range changes, triggered by clicking the pager.</p> <pre><code>SimplePager pager = new SimplePager(); pager.setDisplay(yourDataGrid); //don't forget to add the pager widget to the DOM </code></pre> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload