Hybrid View

  1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    18
    Vote Rating
    0
    deepakse is on a distinguished road

      0  

    Default Unanswered: Fetch all records from store using localstorage proxy

    Unanswered: Fetch all records from store using localstorage proxy


    Hi

    I have created a form using sencha touch 2.1 having three Textfield. i want to do user insert info into textField and save into store.then fetch all the records from store and display on console.i try below code but it gives errors. "Uncaught SyntaxError: Unexpected token for".


    listeners:
    {

    tap:function()
    {
    var i,row;
    Ext.Msg.alert('Hi');
    var store = Ext.create('Ext.data.Store',
    {
    model: 'LoginDemo.model.User'

    });
    var n=Ext.getCmp('txtname').getValue();
    var a=Ext.getCmp('txtadd').getValue();
    var e=Ext.getCmp('txtemail').getValue();

    //loads any existing Search data from localStorage
    store.load();
    //now add some Searches
    store.add({name: n,add: a,mail:e}),

    //finally, save our Search data to localStorage

    for(i=0;i<store.getAllCount();i++)
    {
    row=store.getAt(i);
    store.sync();
    console.log(row);
    }
    }
    }
    },
    can you suggest me what i do wrong in code.

  2. #2
    Sencha User
    Join Date
    Feb 2012
    Location
    Germany
    Posts
    72
    Answers
    8
    Vote Rating
    2
    enno is on a distinguished road

      1  

    Default


    //now add some Searches
    store.add({name: n,add: a,mail:e}), <--- use a ; here

    //finally, save our Search data to localStorage

  3. #3
    Sencha User
    Join Date
    Jan 2013
    Posts
    18
    Vote Rating
    0
    deepakse is on a distinguished road

      0  

    Default


    Thanks
    i used array and push element at the end of array now it works.
    but when i close the browser all the records flush away from an array. so what is the use of localstorage.i want data persist in localstorage how do i achieve that.

  4. #4
    Sencha User
    Join Date
    Jan 2011
    Posts
    134
    Answers
    6
    Vote Rating
    5
    JRS is on a distinguished road

      1  

    Default Good video on youtube with Rohit Ghatol

    Good video on youtube with Rohit Ghatol


    Hi There is really good video on this by Rohit Ghatol on youtube. Should answer all your questions

Thread Participants: 2

Tags for this Thread