I have a Grid hooked into a QueryReadStore. When the grid first loads up I see one request in Firebug. If I sort on a column I'll see two requests with the same Request data and response coming back.
It appears that the 2nd request gets fired the second the first comes back. Is there some option I can set to prevent this or is this a bug in QueryReadStore?
<div dojoType="dojox.data.QueryReadStore"
jsId="dkpStandingsStore"
url="myurl.php";
requestMethod="post"></div>
<div dojoType="dojox.grid.data.DojoData"
jsId="dkpStandingsModel"
store="dkpStandingsStore"
sortFields="[{attribute: '1', descending: true}]"
rowsPerPage="50"
></div>
<div dojoType="dojox.Grid" id="dkp-standings-grid"
model="dkpStandingsModel"
structure="dkp.standingsLayout"
autoHeight="false"
autoWidth="false"
style="width:100%;height:35em;"
></div>
jsId="dkpStandingsStore"
url="myurl.php";
requestMethod="post"></div>
<div dojoType="dojox.grid.data.DojoData"
jsId="dkpStandingsModel"
store="dkpStandingsStore"
sortFields="[{attribute: '1', descending: true}]"
rowsPerPage="50"
></div>
<div dojoType="dojox.Grid" id="dkp-standings-grid"
model="dkpStandingsModel"
structure="dkp.standingsLayout"
autoHeight="false"
autoWidth="false"
style="width:100%;height:35em;"
></div>
In my JavaScript file:
dkp.standingsLayout=[
{ cells: [[
{name: "Name", field:1, width: 'auto'},
{name:"Class", field:2,width:6,formatter:dkp.classFormat},
{name:"Race",field:3,width:6},
{name:"Attended",field:5,width:5},
{name: "Last",field:7, width: 6,formatter: dkp.smartDateFormat},
{name:"Items",field:8,width:3}
]]}
];
{ cells: [[
{name: "Name", field:1, width: 'auto'},
{name:"Class", field:2,width:6,formatter:dkp.classFormat},
{name:"Race",field:3,width:6},
{name:"Attended",field:5,width:5},
{name: "Last",field:7, width: 6,formatter: dkp.smartDateFormat},
{name:"Items",field:8,width:3}
]]}
];

odd formatter behavior
Also, in one of my formatters I'm accessing other data in the row through the model. My formatter looks like this.
var model=this.grid.model;
console.debug("isRowLoaded",model.isRowLoaded(rowIndex));
if(model.isRowLoaded(rowIndex)){
return model.getRow(rowIndex)[1];
}
}
In Firebug I see
"isRowLoaded false" 9 times
and then
"isRowLoaded true" 4 times (I have 4 rows)
Why is it calling the formatter if the row isn't loaded?
So I attempted to hunt this
So I attempted to hunt this down.
As you can see, refresh only gets called once, yet requestRows on the model is called twice somehow. And yet, requestRows appears to only be called once from refresh:
// summary:
// Function to cause the model to re-query the store and rebuild the current viewport.
this.clearData(true);
this.requestRows();
},
I set a number of breakpoints and found only that the second call happens in the getDispatcher function of dojo.connect
// following comments pulled out-of-line to prevent cloning them
// in the returned function.
// - indices (i) that are really in the array of listeners (ls) will
// not be in Array.prototype. This is the 'sparse array' trick
// that keeps us safe from libs that take liberties with built-in
// objects
// - listener is invoked with current scope (this)
return function(){
var ap=Array.prototype, c=arguments.callee, ls=c._listeners, t=c.target;
// return value comes from original target function
var r=t && t.apply(this, arguments);
// invoke listeners after target function
for(var i in ls){
if(!(i in ap)){
ls[i].apply(this, arguments);
}
}
// return value comes from original target function
return r;
}
},
However, this code is pretty obscure and I'm not really sure what's going on. Hopefully someone with more knowledge can see the reason for the double request.
So I created an extremely
So I created an extremely simple demo of this and filed a bug report:
http://trac.dojotoolkit.org/ticket/6567