Opened 6 years ago

Last modified 3 years ago

#16783 new defect

DataStore overwrites query parameters with an empty object

Reported by: pulsar256 Owned by: Kris Zyp
Priority: undecided Milestone: 1.15
Component: Data Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:

Description

(OnDemandGrid?(DataStore?(QueryReadStore?))).set("query",myQuery) - myQuery will be overwritten by DataStore?.js Edit No milestone No one is assigned I've run into an issue when using the DataStore? compatibility layer encapsulating a QueryReadStore? in a OnDemandGrid? grid.

DataStore?'s query Method will mix the Query-Options (start, count, sort, query) provided by the OnDemandList? with the user query object passed via grid.set("query",queryObject). Resulting mixin will override the query property with an empty version obtained from the OnDemanList?'s options within the DataStore?.js/query() method.

my fix was swap the order of objects to mix, so the OnDemanList?'s options come first:

        fetchHandle = this.store.fetch(lang.mixin(options,{
            query: query,
            onBegin: function(count){
                deferred.total.resolve(count);
            },
            onComplete: function(results){
                deferred.resolve(array.map(results, converter));
            },
            onError: function(error){
                deferred.reject(error);
            }
        }));

That allowed the query object to be propagated correctly down to the QueryReadStore?. My Initialization went something like this:

require(["dgrid/OnDemandGrid", "dojo/store/DataStore", "dojox/data/QueryReadStore"],
    function(OnDemandGrid, DataStore, QueryReadStore) {
      var grid = new OnDemandGrid({
        store: new DataStore({ store: new QueryReadStore({ url: "/legacyBackend", requestMethod: "post" }) }),
        selectionMode: "single",
        columns: [
          { label: myLabel, field: "MyLabel" }
          ...
          ...
        ]
      }, "myGridElement");
    }
);

// and within some event handler:
grid.set("query",{foo:'bar',baz:'bork'});

Change History (2)

comment:1 Changed 3 years ago by dylan

Milestone: tbd1.12

comment:2 Changed 3 years ago by dylan

Milestone: 1.131.15

Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.

Note: See TracTickets for help on using tickets.