-
10 Apr 2012 2:34 AM #1
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
-
10 Apr 2012 6:52 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 436
- Answers
- 3108
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
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
29 Oct 2012 8:10 AM #3
But HTML 5 can create a local database, can SENCHA use that ?
-
29 Oct 2012 8:12 PM #4
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.


Reply With Quote