嗨,目前我在我的应用程序中使用了Sencha Touch + Phonegap中的LocalStorage,并且从WCF Rest获得了超过4000条以上的记录。在开发模式期间,我在谷歌浏览器中运行它没有问题,但当我打包并安装在iOS8设备中时,我的应用程序崩溃了。
以下是控制台中的localStorage总长度:
>JSON.stringify(localStorage).length
> 2917665
型号:
Ext.define("QualityAudit.model.DefectMatrix", {
extend: "Ext.data.Model",
config: {
identifier: { type: 'uuid', isUnique: true },
fields: [
{ name: "DefectMatrixID", type: "integer" },
{ name: "CustomerID", type: "integer" },
{ name: "CustomerName", type: "string" },
{ name: "DefectType", type: "integer" },
{ name: "DefectTypeName", type: "string" },
{ name: "Reference", type: "string" },
{ name: "Section", type: "string" },
{ name: "DefectDescription", type: "string" },
{ name: "SeverityID", type: "integer" },
{ name: "SeverityName", type: "string" },
{ name: "IsActive", type: "bool" },
{ name: "CreatedBy", type: "string" },
{ name: "CreatedDate", type: 'date', dateFormat: 'MS' }
]
}
});
商品
defectSync: function (counter, totRecords, callback) {
var me = this;
if (counter == undefined)
counter = 0;
//load defect matrix local local storage
var defectsLocalStore = Ext.getStore('DefectMatrix');
defectsLocalStore.load();
var defectssurl = window.REST_DMGetListAllPaging + counter;
QualityAudit.util.Proxy.doAjaxCall(defectssurl, '',
function (response) {
var data = Ext.JSON.decode(response.responseText); //encode Json List
defectsLocalStore.load({
callback: function (records, operation, success) {
Ext.Array.each(data, function (record) {
counter++;
record.dirty = true;
defectsLocalStore.add(record);
defectsLocalStore.sync();
});
console.log('DECFECT DATA AFTER SYNC: ' + defectsLocalStore.getData().length);
//Check if all records loaded on local storage is equail to total defect rows then complete
if (defectsLocalStore.getData().length >= totRecords) {
console.log('defect loading successfull');
callback();
} else {
//Trigger again until condition is met
me.defectSync(counter, totRecords, callback);
}
},
scope: this
});
},
function (response) {
defectsLocalStore.load();
callback(0);
});
}
是否有人尝试在您的项目中使用webSQL或SQLlite?我找不到任何好的样本。
非常感谢任何帮助和建议。
答案 0 :(得分:1)
我几乎在每个项目中使用SQLite。恕我直言,最好的插件是Cordova/PhoneGap SQLitePlugin。
您可以在页面上找到一些示例,如何使用该插件以及如何在cordova中使用SQLite。
答案 1 :(得分:0)
您可以使用store with proxy:'sql',它将使用WebSQL创建本地数据库。 sql proxy Doc