简体   繁体   中英

sencha touch / phonegap - database

I am developing an app that will need to list countries and then cities. This could obviously be quite a large database - what is the best way to store this data?

I don't want to use a remote database as I would like the app to be useable offline.

I'm open to any format (xml, javascript array, cvs etc)

Use Sencha Touch's Model and Store functionality to read a json web service or file and make it available to your views.

Ext.regModel('Product', {
    fields: [
        {name: "id", type: "int"},
        {name: "pid", type: "int"},
        {name: "type", type: "string"},
        {name: "status", type: "string"},
        {name: "title", type: "string"},
        {name: "content", type: "auto"},
        {name: "date", type: "string"},
        {name: "modified", type: "string"}  
    ]
});


MVCApp.ProductStore = new Ext.data.Store({
    model: 'Product',
    autoLoad: true,
    storeId: 'ProductStore',
    proxy: {
        type: 'ajax',
        id: 'ProductStore',
        url: 'data/nestedProducts.json',
        reader: {
            root: 'items'
        }
    }
});

您可以使用本地json文件,并通过sencha触摸存储(Ext.data.Store)访问此文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM