1
我试图存储在本地存储中,但没有保存。 我需要将两个值作为状态ID和许可证类型存储为1条记录,下次我将更新它。所以商店总是会有如下的1条记录。Sencha Touch 2.0.1.1本地存储没有保存值
{
'stateId': 'NJ',
'licenseType': 'BDL'
}
我想在过去的2天,用不同的选项,但它不是存储。 有人可以告诉我什么可以是我的代码中的问题。
注:我试图测试是使用Chrome浏览器。
商店代码
Ext.define("Sencha.store.TestParams", { extend: "Ext.data.Store",
requires:
[
"Ext.data.proxy.LocalStorage"
],
config: {
model: "Sencha.model.TestParam",
autoSync: true,
proxy: {
type: 'localstorage',
id: 'ezdt-test-params'
}
}
});
型号代码 代码:
Ext.define("Sencha.model.TestParam",
{
extend: "Ext.data.Model",
config:
{
idProperty: 'id',
fields:
[
{ name: 'id', type: 'int' },
{ name: 'stateId', type: 'string' },
{ name: 'licenseType', type: 'string' }
]
}
});
实际的代码保存 代码:我使用的检索储值
var modTestParamInitialValues = Ext.create("Sencha.model.TestParam", {
id: 'ezdt', //Always Same as there will be only one record.
stateId: strSelectedState,
licenseType: strSelectedLicenseType
});
storTestParams.add(modTestParamInitialValues);
storTestParams.sync();
代码。 始终将其打印为未设置
var storTestParams = Ext.getStore("TestParams");
console.log("storTestParams#####-->" + storTestParams);
//storTestParams.load();
if(null != storTestParams)
{
var intTestParamCount = storTestParams.getCount();
if(intTestParamCount == 0)
{
console.log("Not Set");
}
else
{
console.log("Set Correctly");
}
}
else
{
console.log("Set Correctly");
}
我希望我能给出所有的细节。如果您需要更多详情,请告诉我。
感谢您的帮助。 约瑟夫
我确认调用'mymodel.setDirty()'为我工作 – Tjorriemorrie
工程就像一个魅力 – VirtualWorld