Hi all,
I've got some code that requests some data from a servlet, and renders it in a dojox.grid.DataGrid. This seems to be rather slow though! I'm stuck on how to make it faster. Can anyone help out?
I'm testing with
Dojo 1.34 FF & Chrome.
My code remove all items in the dojo.data.ItemFileWriteStore, then adds new ones that come back from a JSON request.
//Define globla var for the WriteStore...
var deltaInfo;
var rawdataDeltaInfo = <s:property value='%{deltaTableData}'/>;
deltaInfo = new dojo.data.ItemFileWriteStore({
data: {
items: rawdataDeltaInfo
}
});
This section of code to remove all the existng data take 2seconds, even though it only has 30 rows. Any ideas how to make this quicker?
function requestJSONFeed(){
// remove all existing data...
var allData = deltaInfo._arrayOfAllItems;
for (i=0;i<allData.length;i++) {
if (allData[i] != null) {
deltaInfo.deleteItem(allData[i]);
}
}
deltaInfo.save();
// make JSON XHR request...
var xhrArgs = {
url: "../secure/jsonServlet",
handleAs: "json",
preventCache: true,
load: function(data) {
// Add new items to the store...
for (i=0;i<data.length;i++) {
deltaInfo.newItem(data[i]);
}
},
error: function(error) {
}
}
//Call the asynchronous xhrGet
var deferred = dojo.xhrGet(xhrArgs);
}
The section of code above to add 30 new items takes 4 seconds. Any ideas on how to make this faster?
Thanks!
Jeff Porter
FINAL CODE...
var xhrArgs = {
url: "../secure/jsonServlet",
handleAs: "json",
preventCache: true,
load: function(datax) {
deltaInfo = new dojo.data.ItemFileWriteStore({data: {items:datax}});
var grid = dijit.byId("gridDeltas");
grid.setStore(deltaInfo);
},
error: function(error) {
}