Sencha Touch에서 모바일 앱을 개발 중이며 중복되지 않고 이전 검색의 세부 정보를 저장할 필요가 있습니다.Sencha Touch 스토어의 고유 값
검색, 저장 및 표시는 잘 작동하지만 동일한 검색을 두 번 수행하면 항목이 내 저장소에 복제됩니다.
나는 상점의 "아이디"가이 일을 할 것이라고 예상했지만 뭔가 이상하게 보입니다.
다음은 상점 코드입니다.
Ext.regModel('sSaved', {
fields: [
{name: 'IDs', type: 'int'},
{name: 'Outward', type: 'string'},
{name: 'Return', type: 'string'},
{name: 'Pickup', type: 'string'},
{name: 'Destination', type: 'string'}
],
proxy: {
type: 'localstorage',
id:'IDs'
}
});
var savedJobs = new Ext.DataView({
store: new Ext.data.Store({
model: 'sSaved',
storeId: 'allSaved'
}),
tpl: new Ext.XTemplate(
'<tpl for=".">',
'<table class="item" style="margin:auto;">',
'<tr><td class="title">ID</td><td>{IDs}</td></tr>',
'<tr><td class="title">Outward</td><td>{Outward}</td></tr>',
'<tr><td class="title">Return</td><td>{Return}</td></tr>',
'<tr><td class="title">Pickup</td><td>{Pickup}</td></tr>',
'<tr><td class="title">Destination</td><td>{Destination}</td></tr>',
'</table>',
'</tpl>'
),
itemSelector: "table.item",
autoHeight:true,
emptyText: 'No Saved Jobs',
autoLoad: true
});
그리고 상점을 설정하는 코드.
var fetched = Ext.decode(result.responseText);
var details = fetched.apiResponse.details;
savedJobs.store.load();
savedJobs.store.add({
"IDs":details.ID,
"Outward":details.Outward,
"Return":details.Return,
"Pickup":details.Pickup,
"Destination":details.Destination
});
savedJobs.store.sync();
어떻게 든 가게를 검색하고 그러나 나는 간단한 방법이 있는지 해요, 값을 추가하기 전에 존재하는지 여부를 확인하여이 문제를 해결할 수 있습니다.
검색 -> 확인 -> 추가가 필요한 접근 방식 인 경우 리소스를 가장 많이 사용하지 않는 방법은 무엇입니까?