dojo dojo.data.ItemFileWriteStore slow ....? [英] dojo dojo.data.ItemFileWriteStore slow....?

查看:170
本文介绍了dojo dojo.data.ItemFileWriteStore slow ....?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码可以从一个servlet请求一些数据,并将其呈现在一个dojox.grid.DataGrid中。这似乎相当缓慢!我坚持如何使它更快。任何人都可以帮忙吗?



我正在测试



Dojo 1.34
FF& Chrome。



我的代码删除了dojo.data.ItemFileWriteStore中的所有项目,然后添加了从JSON请求返回的新项目。

  //为WriteStore定义globla var ... 
var deltaInfo;
var rawdataDeltaInfo =< s:property value ='%{deltaTableData}'/> ;;
deltaInfo = new dojo.data.ItemFileWriteStore({
data:{
items:rawdataDeltaInfo
}
});

这部分代码删除所有的存在数据需要2秒,即使它只有30行。任何想法如何使这个更快?

  function requestJSONFeed(){
//删除所有现有数据...
var allData = deltaInfo._arrayOfAllItems; (i = 0; i< allData.length; i ++){
if(allData [i]!= null){
deltaInfo.deleteItem(allData [i]);

}
}
deltaInfo.save();

//使JSON XHR请求...
var xhrArgs = {
url:../secure/jsonServlet,
handleAs:json
preventCache:true,
load:function(data){
//向商店添加新的项目...
for(i = 0; i< data.length; i ++){
deltaInfo.newItem(data [i]);
}
},
错误:function(error){
}
}

//调用异步xhrGet
var deferred = dojo.xhrGet(xhrArgs);

}



上面的代码部分添加30个新项目需要4秒。任何关于如何使这个更快的想法?



谢谢!



Jeff Porter



最终代码...

  var xhrArgs = {
url:.. / secure / jsonServlet,
handleAs:json,
preventCache:true,
load:function(datax){
deltaInfo = new dojo.data.ItemFileWriteStore :{items:datax}});
var grid = dijit.byId(gridDeltas);
grid.setStore(deltaInfo);
},
错误:功能(错误){
}


解决方案

尝试跳过穿过现有商店的代码,删除每个项目,然后执行 deltaInfo.save()。而是根据您的xhr通话建立一个全新的商店,然后使用 dojox.grid.DataGrid.setStore()


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) {
 }

解决方案

Try skipping the code that walks through the existing store, deletes every item and then does deltaInfo.save(). Instead, create a brand new store based on your xhr call, and then use dojox.grid.DataGrid.setStore().

这篇关于dojo dojo.data.ItemFileWriteStore slow ....?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆