Salam all. i'm tring to test a local storage. i found a code here
http://miamicoder.com/2011/writing-a...cation-part-4/ i modified the code above to be compatible with my app, so i divide it to 4 files: first the store file:
Code:
Ext.regStore('testStore', {
model: 'Note',
sorters: [{
property: 'date',
direction: 'DESC'
}],
proxy: {
type: 'localstorage',
id: 'notes-app-store'
},
getGroupString: function (record) {
if (record && record.data.date) {
return record.get('date').toDateString();
} else {
return '';
}
}
});
second: model file:
Code:
Ext.regModel('Note', {
fields: ['title','narrative']
});
third file is the view which i want to see my notes loaded from the local store :
Code:
App.views.notelist = Ext.extend(Ext.List, {
store: 'testStore',
grouped: true,
emptyText: '<div style="margin:5px;">No notes cached.</div>',
itemTpl: '<div class="list-item-title">{title}</div>' +
'<div class="list-item-narrative">{narrative}</div>',
listeners: {
'render': function (thisComponent)
{
thisComponent.getStore().load();
}
}
});
Ext.reg('notelist', App.views.notelist);
and the fourth file is the view which i insert information to be saved
Code:
App.views.NoteView = Ext.extend(Ext.Panel, {
scroll: 'vertical',
items: [{
xtype: 'formpanel',
id: 'form',
cls : 'form',
items: [
{
xtype: 'fieldset',
title: 'Note',
},
{
xtype: 'textfield',
id : 'Titre',
label: 'Titre'
},
{
xtype: 'textareafield',
id: 'narr',
label: 'Corp',
},
{
xtype: 'button',
flex: 1,
margin: 10,
text: 'Enregistrer',
handler: function()
{
alert ("begin");
var titre = Ext.getCmp("Titre").getValue();
var body = Ext.getCmp("narr").getValue();
var NS = App.views.notelist.getStore();
NS.add({title: titre},
{narrative: body});
NS.sync();
App.views.notelist.refresh();
alert ("end");
}
}
]
}]
});
Ext.reg('NoteView', App.views.NoteView);
but it doesn't work. i don't know where is the mistake (the add in the store dont work)... can anyone help me ? ? thank youu