-
6 Sep 2010 2:00 AM #1
Using dataStore in local (phonegap) apps
Using dataStore in local (phonegap) apps
I was wondering if there is any way developers can make use of the rather neat functionality that comes with using the DataStore when building Phonegap based (or similarly local) apps.
I've tried using the ajax and scripttag reader with both json and xml data but as far as i can tell they both expect the correct mimetype so it won't load your data. This won't work when your app is running nativly using phonegap:
One way to go about this is to simply load the data as a js file wrapping some json in a <script> tag i guess but that would only work for loading it once and the flexibility of using ajax is kinda handy.Code:Ext.regModel('Card', { fields: ['content', 'cls'] }); var store = new Ext.data.Store({ model: 'Card', proxy: { type: 'ajax', url: 'data.xml', reader: { type: 'xml', record: 'card' } }, listeners: { single: true, datachanged: function(){ debug.log("we get this far"); store.each(function(rec){ debug.log("but no records will have loaded:" + rec.get('content')); }); } } }); store.read();
So i guess the question is; is this possible with sencha and if so what is the right way to do it? and if not could this be a future feature? i.e. a localFilesProxy or something along those line...
-
6 Sep 2010 2:04 AM #2
Wouldn't you be better off posting this on a PhoneGap forum? How do you usually load local files with PhoneGap?
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
6 Sep 2010 2:45 AM #3
Hi Evan, perhaps but phonegap is not a framework it just offers some wrappers to access local SDK features and a way to distribute my app adhoc or via the app store. In short you use whatever the framework your using offers or write your own code to handle this usually.
Since i'm using Sencha to build the actual app it would be nice if Sencha offered a way to handle this particular use case. But i can understand if native apps is not where you want to take the framework of course!
-
6 Sep 2010 2:49 AM #4
In this case, you can't access local files via a normal web app, so I assume PhoneGap gives you some API that allows you to do it. Find out what that is.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
6 Sep 2010 2:53 AM #5
will do. and if i find anything workable i'll update this thread just in case anyone else ends up looking for it.
-
6 Sep 2010 10:54 AM #6
-
6 Sep 2010 1:15 PM #7
thanks gabrielstuff! i've found that thread and it's almost what i need but not quite..
Actually i can now load a local xml file using the xmlhttprequest and the file://<absolute path to resources>/data.xml url schema (instead of a relative or http url) so i'm just about there. Only problem is that when the app is built the path is different so i still have to figure out how to get the 'root' resources path for a running app. I'm afraid i'll have to write some custom objective-c for that since it's not supported by Phonegap yet as far as i can tell.
And while a plain XHR seems to work with the file:// schema the same path fails when used with the Sencha datastore so i'll still have to write that myself and throw out my datastore code which is a bit of a pain but to be expected in a beta release i guess.
-
13 Jun 2011 12:02 AM #8
-
13 Jun 2011 1:12 AM #9
sorry no i haven't. i've stopped using Sencha actually, felt too much like using a tank to kill a fly. sticking with lightweight libraries for new projects.
-
21 Nov 2011 7:06 PM #10
Saw this as I was searching... did you ever happen to come back to sencha now that it is over a year later?
Similar Threads
-
Startup Screen - Sencha or Phonegap
By ssdesign in forum Sencha Touch 1.x: DiscussionReplies: 1Last Post: 24 Aug 2010, 3:50 PM -
sencha + phonegap on Android
By emm in forum Sencha Touch 1.x: DiscussionReplies: 1Last Post: 13 Aug 2010, 7:31 AM -
filters local and datastore insert
By EducatedFool in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 6 Feb 2009, 12:16 AM -
Local Array (Datastore) from text file to php query?
By fuzelogic in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 12 Dec 2007, 6:22 PM -
ComboBox "Autocompleter" with local DataStore - problems
By trappy in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 6 Dec 2007, 11:42 PM


Reply With Quote
