sencha touch / phonegap - 数据库

时间:2012-01-08 13:30:08

标签: javascript cordova sencha-touch

我正在开发一个需要列出国家和城市的应用程序。这显然可能是一个非常大的数据库 - 存储这些数据的最佳方式是什么?

我不想使用远程数据库,因为我希望该应用程序可以脱机使用。

我对任何格式(xml,javascript数组,cvs等)开放

2 个答案:

答案 0 :(得分:1)

使用Sencha Touch的模型和商店功能来读取json Web服务或文件,并使其可用于您的视图。

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'
        }
    }
});

答案 1 :(得分:0)

您可以使用本地json文件并使用sencha touch store(Ext.data.Store)访问此文件。

相关问题