ui5 load josn

 

sap.ui.jsview("ui5p.Test01", {

    /** 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 ui5p.Test01
    */ 
    getControllerName : function() {
        return "ui5p.Test01";
    },

    /** 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 ui5p.Test01
    */ 
    createContent : function(oController) {
         
        var mtable=new sap.ui.table.Table('mtable',{title:'testtable'});
    
        mtable.addColumn(new sap.ui.table.Column({
            label: new sap.ui.commons.Label({text: "Last Name"}), 
            template: new sap.ui.commons.TextView({text:"{lastName}"})
          }));
        
         // create some local data
          var naughtyList = [
            {lastName: "Dente", name: "Al", stillNaughty: true},
            {lastName: "Friese", name: "Andy", stillNaughty: true},
            {lastName: "Mann", name: "Anita", stillNaughty: false}
          ];    

          var oModel = new sap.ui.model.json.JSONModel();    
          //type 1
          //oModel.loadData("http://localhost:8080/UI5P/ui5p/data01.json");
          
          //type 2
          oModel.loadData("./ui5p/data01.json");
          
          //type 3
          //oModel.setData(naughtyList);
          
          mtable.setModel(oModel);
          mtable.bindRows("/");
        
        return mtable;
    }

});

 

data01.json 文件内容

[
{"lastName": "Dente", "name": "Al"},
{"lastName": "Friese", "name": "Andy"},
{"lastName": "Mann", "name": "Anita"}
]

 

posted on 2018-02-07 13:05  rojas  阅读(137)  评论(0编辑  收藏  举报