2016-10-06 2 views
0

Ich habe eine Tabelle mit JSONModel implementiert. Jetzt möchte ich 2 Schaltflächen in der Symbolleiste zum Sortieren und Filtern hinzufügen. Wie kann ich das erreichen? Ich habe die Ansicht in JS erstellt, so dass Code-Hilfe in JS geschätzt wird.So implementieren Sie Filtern und Sortieren in UI5-Tabelle (sap.m.Table)

Bitte finden Sie unten genannten Code als Referenz und bitte helfen Sie mir Sortier-und Filtertasten zu implementieren.

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 
     ] 
    }); 
    } 

}); 
+0

Für dynamische Filterungs Kasse: der FacetFilter (hat eine schöne ui) https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.FacetFilter.html#constructor Beispiel aus SAP: https://sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.FacetFilterSimple/preview Für die Sortierung erhalten Sie die Tabelle byId: sap.ui.getCore(). ById ("idTable"). sort ("", SortOrder.Ascending); Wenn SortOrder.Assending nicht funktioniert, können Sie auch eine Zeichenfolge "aufsteigend" verwenden – Beka

Antwort

0

Ich hatte das gleiche Problem. Mein Fazit:

Wenn Sie verwenden möchten sap.m.Table die einzige Möglichkeit, die Eigenschaft useTablePersonalisation zu setzen: „true“ Oder Sie sap.ui.Table verwenden, die zu manipulieren leichter ist, aber es ist hässlich und alt.

Verwandte Themen