markwyner
14 Apr 2011, 10:58 AM
Hello,
I've been given a serious beat down on this issue. I've scoured the forums and read all the API documentation, yet nothing seems to work.
What I expect to happen:
Add an item to localstorage via add()
Navigate to another panel where the data should be pulled in from localstorage
See the newly-added item there
What actually happens:
Add an item to local storage via add()
Navigate to another panel where the data should be pulled from localstorage
Newly-added item is not present
If I refresh my browser the newly-added item appears. So for whatever reason the data isn't be pulled in real time. I have tried the following calls in the panels, models, and stores:
store.load()
store.sync()
None of them immediately force a refreshed connection between a list/panel and the localstorage. I also run a doComponentLayout() and doLayout() on the lists/panels, neither of which produces the newly-added items.
Following is some source code from that process:
// VIEWS FOR IF/ELSE ON GETCOUNT
if (StoreCategories.getCount('catName') == 0) {
var CategoriesPanel = new Ext.Panel({
id: 'categories_panel',
layout: {
type: 'vbox',
flex: 1
},
items: [{
xtype: 'panel',
html: '<div class="HTMLPanel">You haven’t yet added any categories.</div>'
}],
dockedItems: [addEditToolbar]
});
} else {
var CategoriesPanel = new Ext.Panel({
id: 'categories_panel',
layout: 'fit',
items: [{
xtype: 'list',
store: StoreCategories,
itemTpl: '{catName}'
}],
dockedItems: [addEditToolbar]
});
}
// TOOLBAR/BUTTON THAT TRIGGERS THE ADD FORM
var addEditToolbar = new Ext.Toolbar({
title: 'Categories',
items: [{
cls: 'ToolbarIcon',
icon: 'resources/themes/images/icon_add.png',
ui: 'normal',
handler: function() {
CategoriesWrapper.setActiveItem('add_cat', {type:'slide', direction:'up'});
overlayGrip(CategoriesWrapper);
}
}]
});
// MODEL/STORE FOR DATA
Ext.regModel('Categories', {
fields: ['id', 'catName'],
proxy: {
type: 'localstorage',
id: 'category_list'
}
});
var StoreCategories = new Ext.data.Store({
model: 'Categories'
});
StoreCategories.load();
StoreCategories.sort('catName','ASC');
StoreCategories.sync();
// SAVE BUTTON THAT ADDS AN ITEM TO LOCALSTORAGE AND RELOADS THE IF/ELSE PANEL
text: 'Save',
ui: 'confirm',
handler: function() {
var newCat = Ext.getCmp('Cat_Name').getValue();
StoreCategories.add({catName: newCat});
StoreCategories.sync();
CategoriesWrapper.setActiveItem('categories_panel', {type:'slide', direction:'down'});
StoreCategories.sort('catName','ASC');
App.Viewport.tabBar.show();
CategoriesWrapper.doComponentLayout();
App.Viewport.doComponentLayout();
overlayRelease(CategoriesWrapper,StoreCategories);
}
Any thoughts at all? I would love any insight on this. Thanks in advance!
I've been given a serious beat down on this issue. I've scoured the forums and read all the API documentation, yet nothing seems to work.
What I expect to happen:
Add an item to localstorage via add()
Navigate to another panel where the data should be pulled in from localstorage
See the newly-added item there
What actually happens:
Add an item to local storage via add()
Navigate to another panel where the data should be pulled from localstorage
Newly-added item is not present
If I refresh my browser the newly-added item appears. So for whatever reason the data isn't be pulled in real time. I have tried the following calls in the panels, models, and stores:
store.load()
store.sync()
None of them immediately force a refreshed connection between a list/panel and the localstorage. I also run a doComponentLayout() and doLayout() on the lists/panels, neither of which produces the newly-added items.
Following is some source code from that process:
// VIEWS FOR IF/ELSE ON GETCOUNT
if (StoreCategories.getCount('catName') == 0) {
var CategoriesPanel = new Ext.Panel({
id: 'categories_panel',
layout: {
type: 'vbox',
flex: 1
},
items: [{
xtype: 'panel',
html: '<div class="HTMLPanel">You haven’t yet added any categories.</div>'
}],
dockedItems: [addEditToolbar]
});
} else {
var CategoriesPanel = new Ext.Panel({
id: 'categories_panel',
layout: 'fit',
items: [{
xtype: 'list',
store: StoreCategories,
itemTpl: '{catName}'
}],
dockedItems: [addEditToolbar]
});
}
// TOOLBAR/BUTTON THAT TRIGGERS THE ADD FORM
var addEditToolbar = new Ext.Toolbar({
title: 'Categories',
items: [{
cls: 'ToolbarIcon',
icon: 'resources/themes/images/icon_add.png',
ui: 'normal',
handler: function() {
CategoriesWrapper.setActiveItem('add_cat', {type:'slide', direction:'up'});
overlayGrip(CategoriesWrapper);
}
}]
});
// MODEL/STORE FOR DATA
Ext.regModel('Categories', {
fields: ['id', 'catName'],
proxy: {
type: 'localstorage',
id: 'category_list'
}
});
var StoreCategories = new Ext.data.Store({
model: 'Categories'
});
StoreCategories.load();
StoreCategories.sort('catName','ASC');
StoreCategories.sync();
// SAVE BUTTON THAT ADDS AN ITEM TO LOCALSTORAGE AND RELOADS THE IF/ELSE PANEL
text: 'Save',
ui: 'confirm',
handler: function() {
var newCat = Ext.getCmp('Cat_Name').getValue();
StoreCategories.add({catName: newCat});
StoreCategories.sync();
CategoriesWrapper.setActiveItem('categories_panel', {type:'slide', direction:'down'});
StoreCategories.sort('catName','ASC');
App.Viewport.tabBar.show();
CategoriesWrapper.doComponentLayout();
App.Viewport.doComponentLayout();
overlayRelease(CategoriesWrapper,StoreCategories);
}
Any thoughts at all? I would love any insight on this. Thanks in advance!