SAPUI5 - MVC CRUD表无数据

时间:2014-07-09 02:08:16

标签: sapui5

创建了一个sapui5 MVC CRUD应用程序我需要你的帮助。

  1. 为什么视图中没有数据?
  2. 这是一个绑定问题吗?
  3. 我的CRUD.view.xml是否正确?
  4. 如何在单独的文件上调用JSON数据? sap.ui.resource()或jQuery.sap.getModulePath()
  5. 有哪些解决方案?
  6. CRUD.controller.js onInit函数

      onInit: function () {
    
        // JSON data normally on a seperate file
        var oData = {
                ApplicationCollection : [
            {
              "applicationId" : "0001",
              "name" : "John Doe",
              "connectionPath" : "index.html",
              "imagePath" : "Image Path",
              "subApplicationId": "Sub ID",
              "status": "active"
            },
            {
              "applicationId" : "0002",
              "name" : "Jane Doe",
              "connectionPath" : "index.html",
              "imagePath" : "Image Path",
              "subApplicationId": "Sub ID",
              "status": "active"
            },
            {
              "applicationId" : "0003",
              "name" : "Mary Jane",
              "connectionPath" : "index.html",
              "imagePath" : "Image Path",
              "subApplicationId": "Sub ID",
              "status": "active"
            },
            {
              "applicationId" : "0004",
              "name" : "Bob Foo",
              "connectionPath" : "index.html",
              "imagePath" : "Image Path",
              "subApplicationId": "Sub ID",
              "status": "active"
            }
          ]
        };
    
        var oModel = new sap.ui.model.json.JSONModel();
        oModel.setData(oData);
        this.getView().setModel(oModel);
      }
    

    CRUD.view.xml

    <mvc:View
       controllerName="sap.ui.crud.view.CRUD"
       xmlns:mvc="sap.ui.core.mvc"
       xmlns="sap.m">
        <Table
          id="idProductsTable"
          inset="false"
          items="{
            path: '/ApplicationCollection'      
          }">
         <headerToolbar>
           ...
         </headerToolbar>
         <columns> <!-- Columns Header -->
           ...
         </columns> <!-- End of Columns Header -->
         <items> <!-- Column List -->
           <ColumnListItem>
            <cells>
              <Text
                text="{applicationId}" />
              <Text
                text="{name}" />
              <Text
                text="{connectionPath}" />
              <Text
                text="{imagePath}" />
              <Text
                text="{subApplicationId}" />  
              <Text 
                text="{status}" />            
            </cells>
          </ColumnListItem>
         </items> <!-- End of Column List -->
       </Table>
    
    </mvc:View>
    

1 个答案:

答案 0 :(得分:1)

  1. 只需使用<Table ... items="{/ApplicationCollection}">...即可使用
  2. 不一定,只是错误的语法; - )
  3. 是的,应该工作得很好!
  4. 为什么不使用

    var oAnotherModel = new sap.ui.model.json.JSONModel("resources/your_other.json");
    this.getView().setModel(oAnotherModel);
    
  5. 我不完全确定你的意思5)但是,你能详细说明一下吗?

    编辑:查看您在此处工作的代码:http://jsbin.com/biyiq/1/edit

相关问题