1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    14
    Vote Rating
    0
    gunjan.vaishnav.hs is on a distinguished road

      0  

    Default Unanswered: get data from local database into store or directly to list view.

    Unanswered: get data from local database into store or directly to list view.


    Hello all,
    I am using some list view in my sencha touch 2 app. Currently, the data in the list view is fetched from store where i have entered the static data.
    Now i want the list view to be filled from the data from the database. I want to know how to fill the store data: attribute using the sql select queries..
    Also i want that data to be displayed into the list view.

    Here is the sample store.:

    Code:
    Ext.define('myap.store.mystore', {
    	extend: 'Ext.data.Store',
       
    	config: {
    		autoLoad: true,      
    		model: 'myapp.model.myappmodel',
    		grouper: function(record) {
    			return record.get('title');
    		},
    		data: [
    {title: "Title 1", id: "titleOneID"},
    {title: "Title 2", id: "titleTwoID"},
    {title: "Title 3", id: "titleThreeID"},
    {title: "Title 4", id: "titleFourID"},
    {title: "Title 5", id: "titleFifthID"},
    
    
    		]
        }
          
    });

    I am using the above store in the list view and accesing the items of the store like {title} to accessing the title in the itemTpl attribute.

    Now, i want the data to be loaded from the local database of the browser (or the app).

    Any help appreciated.
    Thanks.
    Last edited by mitchellsimoens; 10 Apr 2012 at 6:32 AM. Reason: added [CODE] tags

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,142
    Answers
    3505
    Vote Rating
    855
    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


    You will need a web server like Apache with PHP to get data from a database to server up to your app.
    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
    May 2012
    Posts
    65
    Answers
    8
    Vote Rating
    0
    ehboym is on a distinguished road

      0  

    Default


    But HTML 5 can create a local database, can SENCHA use that ?

  4. #4
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    227
    Answers
    64
    Vote Rating
    20
    haduki will become famous soon enough haduki will become famous soon enough

      0  

    Default


    Code:
    db.transaction(function(tx){
        tx.executeSql('select * from table;', [], 
             function (transaction, results){
                 //todo success
     	     var data=[];
    	     for (var i=0; i<results.rows.length; i++) {
    	         var row = results.rows.item(i);
    	         data[i]={};
    	         data[i].id=row['id'];
    	         data[i].name=row['name'];
                                            
    	     }
                 yourStore.setData(data);
                 //or yourList.setData(data);
    	  },
              function(){
                  //todo error
              }
        );
    })
    I write English by translator.