0

背景:我正在使用列表并存储列表配置。我每次都在进行 Ajax 调用并在列表中显示数据。现在,我想使用本地存储代理。

这是我的代码,

    xtype : 'list',
    id : 'namesList',
    store : {
    id : 'namesStore',
    autoLoad : true,
     fields : ['text', 'value'],
        proxy : {
            type:'ajax',
            url : 'dataFolder/namesList.json',
        reader : {
            type : 'json',
            rootProperty : 'record'
            }
            },
            },
        itemTpl :'<div class = mainContent>{text}</div>',

我的问题是“如何在此配置中使用 localstorageProxy。当我直接添加

proxy : {
    type : 'localstorage',
    id: 'namesListLocalStorage',
    url : 'dataFolder/nameList.json',
    }

它不显示任何记录。任何指针都会有很大帮助。

谢谢

4

1 回答 1

1

我使用了以下机制。

我已经声明了一个远程存储来从服务器获取日期,并声明一个本地存储来与远程存储同步并将数据存储到本地存储。

我的控制器总是检查本地存储中是否没有记录,然后只有远程存储会调用服务器并获取数据。

Once the sync of local store to remotestore is completed, I explictly store localstore as the store for the list using list.setStore method.

Thanks

于 2013-03-10T03:36:41.860 回答