0
我已經使用JSONModel實現了一個表。現在我想在工具欄中添加2個按鈕進行排序和過濾。我怎樣才能做到這一點?我已經在JS中創建了視圖,因此對JS的代碼幫助表示讚賞。如何實現在UI5表中篩選和排序表(sap.m.Table)
請參閱下面提到的代碼以供參考,請幫助我實現排序和過濾按鈕。
sap.ui.jsview("com.sap.view.View1", {
/** Specifies the Controller belonging to this View.
* In the case that it is not implemented, or that "null" is returned, this View does not have a Controller.
* @memberOf controller.View1
*/
getControllerName: function() {
return "com.sap.controller.View1";
},
/** Is initially called once after the Controller has been instantiated. It is the place where the UI is constructed.
* Since the Controller is given to this method, its event handlers can be attached right away.
* @memberOf controller.View1
*/
createContent: function(oController) {
var oColumn1 = new sap.m.Column({
header: new sap.m.Label({text: "ID"})}
);
var oColumn2 = new sap.m.Column({
header: new sap.m.Label({text: "First Name"})}
);
var oColumn3 = new sap.m.Column({
header: new sap.m.Label({text: "Last Name"})}
);
var oColumn4 = new sap.m.Column({
header: new sap.m.Label({text: "Email"})}
);
var oColumn5 = new sap.m.Column({
header: new sap.m.Label({text: "City"})}
);
var oTable = new sap.m.Table("idTabel",{
headerToolbar: new sap.m.Toolbar({
content: [
/* new sap.m.Label({
text: "Sales Order List"
}), new sap.m.ToolbarSpacer({}),*/
new sap.m.Button("idPersonalizationButton", {
icon: "sap-icon://action-settings"
}),
new sap.m.Button("idFSG", {
icon: "sap-icon://filter"
})
]
}),
headerText: "Employee",
columns:[oColumn1,oColumn2,oColumn3,oColumn4,oColumn5],
mode: sap.m.ListMode.SingleSelectMaster,
selectionChange:[oController.onSelect, oController]
});
var oTemp = new sap.m.ColumnListItem({
cells: [new sap.m.Text({text: "{id}"}),
new sap.m.Text({text: "{first_name}"}),
new sap.m.Text({text: "{last_name}"}),
new sap.m.Text({text: "{email}"}),
new sap.m.Text({text: "{city}"})]
});
oTable.bindItems({
path: "/details",
template: oTemp
});
// oTable.setModel(oModel);
return new sap.m.Page({
title: "Simple Table",
content: [oTable
]
});
}
});
對於動態過濾結帳:所述FacetFilter(有一個很好的UI)https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.FacetFilter.html#constructor從 實施例SAP: https://sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.FacetFilterSimple/preview 對於排序獲取表byId:sap.ui.getCore()。byId (「idTable」)。sort(「」,SortOrder.Ascending); 如果SortOrder.Ascending不起作用,您還可以使用字符串「升序」 –
Beka