Skip to Content
author's profile photo
Former Member

How to populate Generic Tiles dynamically with data from Backend?

Hello SAPUI5 people,

I want to populate generic tiles with data from backend using odata service, can anyone guide me how to do this?

I am a beginner so do not have any idea about populating tiles with data coming from backend.

Thank you,

Regards,

Chetna

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    author's profile photo
    Former Member
    Mar 18, 2015 at 10:14 AM

    copy paste this code in the createcontent method.

      var oModel = new sap.ui.model.odata.ODataModel("proxy/http/services.odata.org/V3/(S(hwii2w0uoa1wgczn3bian230))/OData/OData.svc/");
      oModel.oHeaders = {
      "DataServiceVersion" : "3.0",                   // first check the oModel data version, since we are using data version 3 in the 
      // in the service URL that we are accessing, we set out oModel version from 2 to 3
      "MaxDataServiceVersion":  "3.0" // if not we get an error
      };
    
      sap.ui.getCore().setModel(oModel);
    
    
    
       var tileContainer = new sap.m.TileContainer("tileid",{
         height: '300px',
         tiles : [
           new sap.m.CustomTile({
             content: new sap.m.Text({text: 'Sample example'})
           })
         ]
       });
    
    
      // var tile = sap.ui.getCore().byId("tileid");
       tileContainer.setModel(oModel);
       
       var template = new sap.m.StandardTile({
         title : "{Name}"
       });
       
       
       tileContainer.bindAggregation(
         'tiles',
         '/Products',template
         
         
       );
       
       
       
       tileContainer.placeAt('content');
    
    
    
    
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      sap.ui.jsview("test1.abc", {

      getControllerName : function() {

      return "test1.abc";

      },

      createContent : function(oController) {

      var oModel = new sap.ui.model.json.JSONModel(" ", false);

      sap.ui.getCore().setModel(oModel);

      var tileContainer = new sap.m.TileContainer("ID",{

      height: '300px',

      tiles : [

      new sap.m.CustomTile({

      content: new sap.m.Text({text: 'Sample example'})

      })

      ]

      });

      // var tile = sap.ui.getCore().byId("tileid");

      tileContainer.setModel(oModel);

      var template = new sap.m.StandardTile({

      title : "{TILE_NAME}"

      });

      tileContainer.bindAggregation(

      'tiles',

      '/UserSet',template

      );

      tileContainer.placeAt('content');

      }

      });

      Why this is not working???

  • Mar 18, 2015 at 09:33 AM
    Add comment
    10|10000 characters needed characters exceeded