Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Bug: ListGrid issues fetch even though setAutoFetchData(false)

$
0
0
Hi Isomorphic,

please see this minimal testcase (based on builtInDS) showing a unnecessary fetch even though setAutoFetchData(false) is set.
The fetch results in a DS Console warning "13:05:05.810:XRP0:WARN:The ResultSet's cache was invalidated while the following request was outstanding".

Tested with v9.1p_2014-06-29 in FF26 DevMode.

BuiltInDS.java
Code:

package com.smartgwt.sample.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.data.AdvancedCriteria;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.rpc.RPCManager;
import com.smartgwt.client.types.OperatorId;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.util.PageKeyHandler;
import com.smartgwt.client.util.Page;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.layout.VLayout;

public class BuiltInDS implements EntryPoint {
        private VLayout vL;
        private ListGrid boundList;
        private ListGrid boundList2;

        public void onModuleLoad() {
                final DataSource animals = DataSource.get("animals");
                KeyIdentifier debugKey = new KeyIdentifier();
                debugKey.setCtrlKey(true);
                debugKey.setKeyName("D");

                Page.registerKey(debugKey, new PageKeyHandler() {
                        public void execute(String keyName) {
                                SC.showConsole();
                        }
                });
                vL = new VLayout(10);

                boundList = new ListGrid(animals) {
                        {
                                setHeight(400);
                                setWidth(800);

                                setAutoFetchData(false);
                                setInitialSort(new SortSpecifier[] { new SortSpecifier("scientificName", SortDirection.ASCENDING) });

                                ListGridField commonName = new ListGridField("commonName");
                                setFields(commonName);
                        }
                };

                boundList2 = new ListGrid(animals) {
                        {
                                setHeight(400);
                                setWidth(800);

                                setAutoFetchData(false);
                                setSort(new SortSpecifier[] { new SortSpecifier("scientificName", SortDirection.DESCENDING) });

                                // This has a displayField of "commonName" in the ds.xml file!
                                ListGridField scientificName = new ListGridField("scientificName");
                                setFields(scientificName);
                        }
                };

                vL.setMembers(boundList, boundList2);

                RPCManager.startQueue();
                boundList.fetchData(new AdvancedCriteria("lifeSpan", OperatorId.LESS_THAN, 50));
                boundList2.fetchData(new AdvancedCriteria("lifeSpan", OperatorId.GREATER_OR_EQUAL, 50));
                RPCManager.sendQueue();

                vL.draw();
        }
}

Change to animals.ds.xml:
Code:

<field name="scientificName"  title="Scientific Name"    type="text"  primaryKey="true"  required="true" displayField="commonName" />

Interesting observation 1:
In RPC-Tab of the Dev Console, it is for the unnecessary fetch:
sortBy:[
"-commonName"
]

while it is
sortBy:[
"-scientificName"
]

for the queued fetch.

Interesting observation 2:
If you remove "setFields(scientificName);" (so no setFields() for that ListGrid), the bug is gone.

Interesting observation 3:
If you move "vL.draw();" above the RPC-Manager-block, the bug is gone.

Unfortunately I don't have these options in my app.

Best regards,
Blama

Viewing all articles
Browse latest Browse all 4756

Trending Articles