这是我正在使用的代码:
getHeaderFooterOptions: function() {
var that = this;
var oHeaderFooterOptions = {
sI18NMasterTitle: "MASTER_TITLE",
buttonList: []
};
oHeaderFooterOptions.oFilterOptions = {
onFilterPressed: jQuery.proxy(that.onShowFilter, that)
};
var sortItems = [];
var sortText=null;
var sortKey = null;
var sortKey = "WiCreatedAt";
sortItems.push({
key: "WiCreatedAt",
text: "Descending"
});
sortItems.push({
key: "WiCreatedAt",
text: "Ascending"
});
oHeaderFooterOptions.oSortOptions = {
aSortItems: sortItems,
sSelectedItemKey: "WiCreatedAt",
onSortSelected: jQuery.proxy(that.handleSort, that)
};
return oHeaderFooterOptions;
},
handleSort: function(sSortKey) {
//alert("msg");
if (sSortKey === "WiCreatedAt" ) {
oSorter = new sap.ui.model.Sorter(sSortKey,false);
}
else if (sSortKey === "WiCreatedAt" ) {
oSorter = new sap.ui.model.Sorter(sSortKey, true);
}
this.getList().getBinding("items").sort(oSorter);
},
我们有没有办法按照我们在oHeaderFooterOptions.oSortOptions对象中传递密钥的方式传递文本,我们如何获得像aSortItems和sSelectedItemKey这样的属性,是否有任何API?
答案 0 :(得分:1)
我们试图了解这个问题。请看下面的代码:
getHeaderFooterOptions: function() {
var that = this;
var oHeaderFooterOptions = {
sI18NMasterTitle: "MASTER_TITLE",
buttonList: []
};
oHeaderFooterOptions.oFilterOptions = {
onFilterPressed: jQuery.proxy(that.onShowFilter, that)
};
var sortItems = [];
var sortText=null;
sortItems.push({
key: "Descending",
text: "WiCreatedAt sorted descending"
});
sortItems.push({
key: "Ascending",
text: "WiCreatedAt sorted ascending"
});
oHeaderFooterOptions.oSortOptions = {
aSortItems: sortItems,
sSelectedItemKey: "WiCreatedAt",
onSortSelected: jQuery.proxy(that.handleSort, that)
};
return oHeaderFooterOptions;
},
handleSort: function(sSortKey) {
//alert("msg");
if (sSortKey === "Ascending" ) {
oSorter = new sap.ui.model.Sorter("WiCreatedAt",false);
}
else if (sSortKey === "Descending" ) {
oSorter = new sap.ui.model.Sorter("WiCreatedAt", true);
}
this.getList().getBinding("items").sort(oSorter);
},
另请参阅SAP WebIDE中的示例应用程序“管理产品”。