2012-01-08 75 views
0

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

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

我接受任何格式(XML,JavaScript数组,CVS等)

回答

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

你可以使用一个本地JSON文件和访问这其中一个煎茶触摸店(Ext.data.Store)。