cancel
Showing results for 
Search instead for 
Did you mean: 

how to create tiles dynamically based on odata response data?

Former Member
0 Kudos

hi,

iam performing an odata read from controller of ,say login view and passing data to another view(dashboard) like below

OData.read({ requestUri:

  "url",

  headers: { "X-Requested-With": "XMLHttpRequest", "sap-user" : username, "sap-password" : password,  "Content-Type": "application/atom+xml" },

   },

   function (data) {

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

   var myData = {};

var jsonDashboard = {"mycollection":[]};

for(i = 0;i<data.results.length;i++){

//code for filling jsonDashboard array

}

myData.Products = data.results;

   myData.Dashboard = jsonDashboard.mycollection;

   oModel.setData(myData);

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

  //  sap.ui.getCore().setModel(oModel, "mydashboardModel");

   sap.ui.core.BusyIndicator.hide();

  //  sap.ui.getCore().getModel("mydashboardModel").updateBindings(true);

    app.to("Dashboard",data);

   },

 

   function(err){

  // window.alert("error: "+ err.message);

  // bsydialog.close();

  sap.ui.core.BusyIndicator.hide();

             window.alert("error");

   }

  );

what i need is to create tiles based on myData.Dashboard data in dashboard view..

myData will look like

var myData = { "Products":[{

                                         product : "Prod 1",

                                         revenue : 500000

                                       }, {

                                         product : "Prod 2",

                                         revenue : 700000

                                         }],

                        "Dashboard":[{

                                         module : "sd",

                                         count : 5,

                                        },

                                        {

                                         module : "mm",

                                         count : 6

                                             }]

                          };

data may varry

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor
0 Kudos

HI Rajeesh

Will this help?

Example

-D

Former Member
0 Kudos

Hi Dennis,

Thanks for the light.

i used

var container = new sap.m.TileContainer("idTileContainer", {

   allowAdd : true,

   editable : false,

  });

  var moduleTile = new sap.m.StandardTile({

       title : '{Module}',

       number: '{Count}'

  });

  container.bindAggregation("tiles", "/Graph", moduleTile);

now it work fine

Regards

Former Member
0 Kudos

Hi Dennis,

after clicking the tile list page is displayed.when i press navbutton the tiles does not show up?why?

former_member182862
Active Contributor
0 Kudos

HI Raheesh

Can you update my JSBin to reflect the issues that you are facing?

Thanks

-D

Former Member
0 Kudos

Hi Dennis,

The problem is solved.Actually i was binding different data to same model in the next page.

Regards

Former Member
0 Kudos

Hi Dennis,

Can We use custom tile instead of standard tile inside tilecontainer here???

Regards

former_member182862
Active Contributor
0 Kudos

of course.

Former Member
0 Kudos

How?

can you show me example. I tried replacing customtile instead of standard tile. but errored out

Answers (1)

Answers (1)

nabheetscn
Active Contributor
0 Kudos

Hi Rajessh

I would recommend you to search first before posting this requirement

A simple search has shown me

Nabheet

Former Member
0 Kudos

Hi nabheet,

I have seen that.but my requirement is different i need tiles in the first page before showing the list page.

Regards

nabheetscn
Active Contributor
0 Kudos

Hi Rajesh

I believe you can use the same concept to do the same. I will try to create a working example

Thanks

Nabheet

nabheetscn
Active Contributor
0 Kudos

Hi Rajesh

Below is an example of creating tiles on homepage. It is using the JSON data which you can replace with your oData calls

https://gist.github.com/elsewhat/6078885

Thanks

Nabheet

Former Member
0 Kudos

web page not available.i dont want my data to bind to a list and then create tile.

Former Member
0 Kudos

Hi

would you create an example in jsbin.com .when calling odata in the view's create content part.it execute first when the app start.that causes serious problems

regards