1. #1
    Sencha User
    Join Date
    Mar 2012
    Location
    Tunisia
    Posts
    74
    Vote Rating
    1
    zied jouini is on a distinguished road

      0  

    Default Unanswered: Add in Local Storage

    Unanswered: Add in Local Storage


    SALAM
    I try to use local storge of sencha touch from many days but i don't find a solution.
    here is my store:

    Code:
    Ext.regStore('NotesStore', {
        model: 'NoteModel',
        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 '';
            }
        }
    });
    App.stores.notesStore = Ext.StoreMgr.get('NotesStore');
    and my model:
    Code:
    Ext.regModel('NoteModel', {
        idProperty: 'id',
        fields: [
            { name: 'id', type: 'int' },
            { name: 'date', type: 'date', dateFormat: 'c' },
            { name: 'title', type: 'string' },
            { name: 'narrative', type: 'string' }
        ],
        validations: [
            { type: 'presence', field: 'id' },
            { type: 'presence', field: 'title', message: 'Please enter a title for this note.' }
        ]
    });
    and my view:

    Code:
    App.views.NoteEditorView = Ext.extend(Ext.form.FormPanel, {
    
    
        items: [{
            xtype: 'textfield',
            name: 'title',
            label: 'Title',
            required: true
        }, {
            xtype: 'textareafield',
            name: 'narrative',
            label: 'Narrative'
        }]
    });
    Ext.reg('NoteEditorView', App.views.NoteEditorView);
    and in my controller file i add:
    Code:
    // editer action
    editer: function()
    {
        
            this.editerView = this.render({
                xtype: 'NoteEditorView',
            });
    
    
    var backBtn = this.application.viewport.query('#backBtn')[0];
    backBtn.show(); 
    backBtn.setHandler(function(){
         Ext.dispatch({
            controller: 'Home',
            action: 'list',
            historyUrl: 'Home/list',
           animation: {
            type: 'slide',
            reverse: true,
        },
    
    
        });
    });
    
    
    var nouv = this.application.viewport.query('#nouv')[0];
    nouv.hide();
    
    
    var save = this.application.viewport.query('#save')[0];
    save.show();
    save.setHandler(function(){
    alert ("add begin");
    var currentNote = App.views.NoteEditorView.getRecord();
    App.views.NoteEditorView.updateRecord(currentNote);
    var errors = currentNote.validate();
            if (!errors.isValid()) {
    			currentNote.reject();
                Ext.Msg.alert('Wait!', errors.getByField('title')[0].message, Ext.emptyFn);
                return;
            }
    
    
            if (null == App.stores.notesStore.findRecord('id', currentNote.data.id)) {
                App.stores.notesStore.add(currentNote);
               
            } else {
                 currentNote.setDirty();
            }
    
    
            App.stores.notesStore.sync();
             alert ("add done");
            App.stores.notesStore.sort([{ property: 'date', direction: 'DESC'}]);
    
    
            App.views.NoteList.refreshList();
    
    
    
    
         Ext.dispatch({
            controller: 'Home',
            action: 'list',
            historyUrl: 'Home/list',
           animation: {
            type: 'slide',
            reverse: true,
                       },
    
    
                     });
    
    
    
    
    });
    
    
    
    
    
    
        this.application.viewport.setActiveItem(this.editerView);
    },
    when i execute this code the first alert appear:
    alert ("add begin");
    but the second aler don't appear
    alert ("add done");
    I think that my call to the store is wrong, but i don't know how correct it
    how can i fix it please
    thank you.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,780
    Answers
    3465
    Vote Rating
    833
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Have any errors?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Location
    Tunisia
    Posts
    74
    Vote Rating
    1
    zied jouini is on a distinguished road

      0  

    Default


    SALAM
    No i haven't any error. i work with notepad it don't show me any message. my call to Stor is it correct ? or what kind of modification have i to do ?

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi