0
votes

Created a sapui5 MVC CRUD application i need your help.

  1. Why is there No Data in the view?
  2. Is it a binding problem?
  3. Is my CRUD.view.xml correct?
  4. How can i call JSON data on seperate file? sap.ui.resource() or jQuery.sap.getModulePath()
  5. What are the solutions?

CRUD.controller.js onInit function

  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

1 Answers

1
votes
  1. Simply use <Table ... items="{/ApplicationCollection}">... and it should work
  2. Not necessarily, just wrong syntax ;-)
  3. Yup, should work just fine!
  4. Why not use

    var oAnotherModel = new sap.ui.model.json.JSONModel("resources/your_other.json");
    this.getView().setModel(oAnotherModel);
    

I'm not entirely sure what you mean with 5) though, can you elaborate a bit more?

EDIT: See a your code working here : http://jsbin.com/biyiq/1/edit