【问题标题】:sencha touch / phonegap - databasesencha touch / phonegap - 数据库
【发布时间】:2012-01-08 13:30:08
【问题描述】:

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

我不想使用远程数据库,因为我希望应用可以离线使用。

我可以接受任何格式(xml、javascript 数组、cvs 等)

【问题讨论】:

    标签: javascript cordova sencha-touch


    【解决方案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'
            }
        }
    });
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多