1. #1
    Sencha User
    Join Date
    Jun 2010
    Location
    The Hague
    Posts
    15
    Vote Rating
    0
    tijs is on a distinguished road

      0  

    Default 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:

    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();
    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.

    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...

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,917
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

  3. #3
    Sencha User
    Join Date
    Jun 2010
    Location
    The Hague
    Posts
    15
    Vote Rating
    0
    tijs is on a distinguished road

      0  

    Default


    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!

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,917
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

  5. #5
    Sencha User
    Join Date
    Jun 2010
    Location
    The Hague
    Posts
    15
    Vote Rating
    0
    tijs is on a distinguished road

      0  

    Default


    will do. and if i find anything workable i'll update this thread just in case anyone else ends up looking for it.

  6. #6
    Sencha User
    Join Date
    Jul 2010
    Location
    Paris, France
    Posts
    257
    Vote Rating
    0
    gabrielstuff is on a distinguished road

      0  

  7. #7
    Sencha User
    Join Date
    Jun 2010
    Location
    The Hague
    Posts
    15
    Vote Rating
    0
    tijs is on a distinguished road

      0  

    Default


    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.

  8. #8
    Ext JS Premium Member
    Join Date
    Sep 2010
    Posts
    52
    Vote Rating
    1
    aicom is on a distinguished road

      0  

    Default


    Quote Originally Posted by tijs View Post
    will do. and if i find anything workable i'll update this thread just in case anyone else ends up looking for it.
    Have you find a solution? I also need to load a local file with the data using a phonegap webapp. I'll appreciate very much any help.

  9. #9
    Sencha User
    Join Date
    Jun 2010
    Location
    The Hague
    Posts
    15
    Vote Rating
    0
    tijs is on a distinguished road

      0  

    Default


    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.

  10. #10
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    San Antonio, TX
    Posts
    93
    Vote Rating
    0
    jnotti is on a distinguished road

      0  

    Default


    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

  1. Startup Screen - Sencha or Phonegap
    By ssdesign in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 24 Aug 2010, 3:50 PM
  2. sencha + phonegap on Android
    By emm in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 13 Aug 2010, 7:31 AM
  3. filters local and datastore insert
    By EducatedFool in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 6 Feb 2009, 12:16 AM
  4. Local Array (Datastore) from text file to php query?
    By fuzelogic in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 12 Dec 2007, 6:22 PM
  5. ComboBox "Autocompleter" with local DataStore - problems
    By trappy in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 6 Dec 2007, 11:42 PM

Thread Participants: 5

Tags for this Thread