ローカル ストレージに保存しようとしていますが、保存されません。状態 ID とライセンス タイプとして 2 つの値を 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();
ストアの値を取得するために使用しているコード。常に Not Set として印刷
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");
}
すべての詳細を教えていただければ幸いです。詳細が必要な場合は、お知らせください。
ご協力いただきありがとうございます。ジョセフ