ItemFileWriteStore:如何更改数据? [英] ItemFileWriteStore: how to change the data?

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

问题描述

我想更改我的dojo.data.ItemFileWriteStore中的数据。



目前我有...

  var rawdataCacheItems = [{'cachereq':'14:52:03','name':'Test1','cacheID':'3','ver' : '7'}]; 
var cacheInfo = new dojo.data.ItemFileWriteStore({
data:{
identifier:'cacheID',
label:'cacheID',
items:rawdataCacheItems
}
});

我想做一个XHR请求来获取要呈现的数据的新JSON字符串。



我无法解决的是如何更改ItemFileWriteStore所持有的项目中的数据。



任何人都可以指向正确的方向?



感谢
Jeff Porter

解决方案

我会向Alex Cheng发送+1,因为他的信息引导我解决。



这是我如何解决我的问题



我的JSONExtractor类...

  private String setupCacheTabData() 
{
JSONArray jsonList = new JSONArray();

列表< IDataDelivery> cacheDeliveryRecords = service.getCacheDeliveryRecords();

(IDataDelivery缓存:cacheDeliveryRecords)
{
JSONObject jsonO = new JSONObject();

{
jsonO.put( cacheID,cache.getCacheID());
jsonO.put(cacheversion,cache.getVersion());
jsonList.put(jsonO);
}
catch(Exception e)
{
log.error(解码用于JSON的CACHE数据库行错误(WILL SKIP):CACH_ID =+ cache.getCacheID() E);
}
}

return jsonList.toString()。replace(\,');
/ pre>

}



我的Javascrip代码...

  var cacheInfo; 

var rawdataCacheInfo =< s:property value ='%{cacheString}'/> ;;
cacheInfo = new dojo.data.ItemFileWriteStore({
data:{
identifier:'cacheId',
label:'cacheId',
items:rawdataCacheInfo
}
});

函数do(){
var xhrArgs = {

url:../secure/jsonServlet?class=JSONExtractor&startDate= + startDateValue +& startTime =+ startTimeValue,
handleAs:json,
preventCache:true,
load:function(data){
//删除项目。
var allData = cacheInfo._arrayOfAllItems;
for(i = 0; i< allData.length; i ++){
if(allData [i]!= null){
cacheInfo.deleteItem(ALLDATA [I]);
}
}
//保存删除项目。
ddInfo.save();
//添加新项目
for(i = 0; i< data.length; i ++){
cacheInfo.newItem(data [i]);
}

},
错误:功能(错误){
}
}
}


I'd like to change the data in my dojo.data.ItemFileWriteStore.

Currently I have...

var rawdataCacheItems = [{'cachereq':'14:52:03','name':'Test1','cacheID':'3','ver':'7'}];
var cacheInfo = new dojo.data.ItemFileWriteStore({
        data: {
            identifier: 'cacheID',
            label: 'cacheID',
            items: rawdataCacheItems
        }
    });

I'd like to make a XHR request to get a new JSON string of the data to render.

What I can't work out is how to change the data in the "items" held by ItemFileWriteStore.

Can anyone point me in the correct direction?

Thanks Jeff Porter

解决方案

I'll give +1 to Alex Cheng since he info lead me to the solution.

This is how I solved my problem..

My JSONExtractor class...

private String setupCacheTabData()
{
JSONArray jsonList = new JSONArray();

List<IDataDelivery> cacheDeliveryRecords = service.getCacheDeliveryRecords();

for (IDataDelivery cache : cacheDeliveryRecords)
{
  JSONObject jsonO = new JSONObject();
  try
  {
    jsonO.put("cacheID", cache.getCacheID());
    jsonO.put("cacheversion", cache.getVersion());
    jsonList.put(jsonO);
  }
  catch (Exception e)
  {
    log.error("Error decoding CACHE database row for JSON (WILL SKIP): CACH_ID=" + cache.getCacheID(), e);
  }
}

return jsonList.toString().replace("\"", "'");

}

My Javascrip code...

var cacheInfo;

var rawdataCacheInfo = <s:property value='%{cacheString}'/>;
cacheInfo = new dojo.data.ItemFileWriteStore({
        data: {
            identifier: 'cacheId',
            label: 'cacheId',
            items: rawdataCacheInfo
        }
    });

function do() {
    var xhrArgs = {

        url: "../secure/jsonServlet?class=JSONExtractor&startDate="+startDateValue+"&startTime="+startTimeValue,
        handleAs: "json",
        preventCache: true,
        load: function(data) {
            // remove items...
            var allData = cacheInfo._arrayOfAllItems;
            for (i=0;i<allData.length;i++) {
                if (allData[i] != null) {
                    cacheInfo.deleteItem(allData[i]);
                }
            }
            // save removal of items.
            ddInfo.save();
            // add new items
            for (i=0;i<data.length;i++) {
                cacheInfo.newItem(data[i]);
            }

        },
        error: function(error) {
        }
    }
}

这篇关于ItemFileWriteStore:如何更改数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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