我有'電影'模型,並在Ext.data.Store中保存數據。電影顯示在gridPanel中。給予搜索參數並點擊按鈕存儲後重新加載。ExtJS - localStorage
現在,我試圖使用localStorage。它應該將數據保存在監聽器的功能內部:
listeners: {
'click': function() {
movieDataStore.sync();
var textValue = Ext.getCmp("searchFieldId").getValue();
movieDataStore.load({
params : {
start : 0,
limit : 25,
t : textValue
}
});
}
}
我應該怎麼做?
UPDATE V1
如果我初始化這樣的緩存變量我會用Ext.state.LocalStorageProvider:
var movieLocalCacheStore = Ext.state.LocalStorageProvider.create();
var movieGridPanel = Ext.create('Ext.grid.Panel', {
store : movieDataStore,
tbar : [ 'Search', {
xtype : 'textfield',
name : 'searchField',
id: 'searchFieldId',
emptyText : 'Put movie title here',
hideLabel : true,
width : 200
}, {
xtype : 'button',
text : 'Search',
tooltip : 'Search for movie',
listeners: {
'click': function() {
var textValue = Ext.getCmp("searchFieldId").getValue();
movieDataStore.load({
params : {
start : 0,
limit : 25,
t : textValue
}
});
movieDataStore.sync();
movieGridPanel.getView().refresh();
//localStorage.setItem(textValue, movieDataStore.getAt(0));
movieLocalCacheStore.set(textValue, movieDataStore.getAt(0));
}
}
} ]
});
?
我有一個名爲'MovieModel'的模型。是否movieDataStore.getAt(0)
獲取對象的正確方法?
我應該如何檢查是否有緩存的搜索結果(並加載到movieDataStore/movieGridPanel)?
感謝,@Abdel Olakara的交代。我用'LocalStorageProvider'推出了我更新的源代碼 – bontade