forceSelection似乎沒有任何關係,因爲我向隨後選擇的數據存儲添加了一個真正的新記錄。因此顯示的文本對應於實際的記錄。我現在已經掌握了它的工作。當用戶按下搜索按鈕
function getCookie() {
if(Ext.util.Cookies.get('ticketIndexFilter') == null)
return;
var filterSet = Ext.ComponentMgr.get('additionalFilterSet');
var cookie = Ext.decode(Ext.util.Cookies.get('ticketIndexFilter'));
txtNummer.setValue(cookie.TicketNr);
if(cookie.datumVan != null && cookie.datumVan != ""){
datVan.setValue(cookie.datumVan.substr(0, 10));
filterSet.expand();
}
if(cookie.datumTm != null && cookie.datumTm != ""){
datTm.setValue(cookie.datumTm.substr(0, 10));
filterSet.expand();
}
if(cookie.relationId != null && cookie.relationId != "") {
var recDef = Ext.data.Record.create([
{name: 'Id', type: 'int'},
{name: 'Name', type: 'string'}
]);
var rec = new recDef({
Id: cookie.relationId,
Name: cookie.relationName
}, cookie.relationId);
relatieStore.add(rec);
relatieCombo.setValue(cookie.relationId);
}
if(cookie.cobblerContactId != null && cookie.cobblerContactId != "") {
var recDef = Ext.data.Record.create([
{name: 'Id', type: 'int'},
{name: 'Achternaam', type: 'string'}
]);
var rec = new recDef({
Id: cookie.cobblerContactId,
Achternaam: cookie.cobblerContactName
}, cookie.cobblerContactId);
behandelaarStore.add(rec);
behandelaarCombo.setValue(cookie.cobblerContactId);
filterSet.expand();
}
if(cookie.statusId != null && cookie.statusId != "") {
var recDef = Ext.data.Record.create([
{name: 'Id', type: 'int'},
{name: 'Naam', type: 'string'}
]);
var rec = new recDef({
Id: cookie.statusId,
Naam: cookie.statusName
}, cookie.statusId);
statusStore.add(rec);
statusCombo.setValue(cookie.statusId);
filterSet.expand();
}
if(cookie.priorityId != null && cookie.priorityId != "") {
var recDef = Ext.data.Record.create([
{name: 'Id', type: 'int'},
{name: 'Naam', type: 'string'}
]);
var rec = new recDef({
Id: cookie.priorityId,
Naam: cookie.priorityName
}, cookie.priorityId);
prioriteitStore.add(rec);
prioriteitCombo.setValue(cookie.priorityId);
filterSet.expand();
}
if(cookie.relationContactId != null && cookie.relationContactId != "") {
var recDef = Ext.data.Record.create([
{name: 'Id', type: 'int'},
{name: 'Achternaam', type: 'string'}
]);
var rec = new recDef({
Id: cookie.relationContactId,
Achternaam: cookie.relationContactName
}, cookie.relationContactId);
contactStore.add(rec);
contactCombo.setValue(cookie.relationContactId);
filterSet.expand();
}
if(cookie.categoryId != null && cookie.categoryId != "") {
var recDef = Ext.data.Record.create([
{name: 'Id', type: 'int'},
{name: 'Naam', type: 'string'}
]);
var rec = new recDef({
Id: cookie.categoryId,
Naam: cookie.categoryName
}, cookie.categoryId);
categorieStore.add(rec);
categorieCombo.setValue(cookie.categoryId);
filterSet.expand();
}
//finally, an easy one
opgelostBox.setValue(cookie.finalized);
}
function setCookie(){
var filterPresets = {
TicketNr: txtNummer.getValue(),
datumVan: datVan.getValue(),
datumTm: datTm.getValue(),
relationId: relatieCombo.getValue(),
relationName: relatieCombo.getValue() == "" ? null : relatieStore.getById(relatieCombo.getValue()).get('Name'),
cobblerContactId: behandelaarCombo.getValue(),
cobblerContactName: behandelaarCombo.getValue() == "" ? null : behandelaarStore.getById(behandelaarCombo.getValue()).get('Achternaam'),
statusId: statusCombo.getValue(),
statusName: statusCombo.getValue() == "" ? null : statusStore.getById(statusCombo.getValue()).get('Naam'),
priorityId: prioriteitCombo.getValue(),
priorityName: prioriteitCombo.getValue() == "" ? null : prioriteitStore.getById(prioriteitCombo.getValue()).get('Naam'),
relationContactId: contactCombo.getValue(),
relationContactName: contactCombo.getValue() == "" ? null : contactStore.getById(contactCombo.getValue()).get('Achternaam'),
categoryId: categorieCombo.getValue(),
categoryName: categorieCombo.getValue() == "" ? null : categorieStore.getById(categorieCombo.getValue()).get('Naam'),
finalized: opgelostBox.getValue()
};
Ext.util.Cookies.set('ticketIndexFilter', Ext.encode(filterPresets));
}
setCookie方法被調用。在Ext.OnReady中調用getCookie來預設控件。我花了將近10個小時的時間,所以我想我會分享。
的第一篇文章中包含一個錯誤:cookie.CobblerContactName而不是cookie.cobblerContactName
forceSelection似乎沒有過的問題。只要我的8小時過期,我可以發佈這個問題的答案,即實際運行的代碼。 – Paul1977 2012-03-13 15:08:04