Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3354

Re: Standard tiles with data binding

$
0
0

I finally solved it :-) Indeed it seems that you cannot bind the press event itself. So what I now did was create an parameter id-tile in the json file which has the value of the views that are part of the application. So the JSON file looks like:

{

  "TileCollection" : [

    {

      "id-tile": "maintenance",

      "icon" : "edit",

      "type" : "Monitor",

      "info" : "Central",

      "title" : "Global MDM"

    },

    {

      "id-tile": "assignment",

      "icon" : "activity-assigned-to-goal",

      "type" : "Monitor",

      "info" : "Local",

      "title" : "Product and Customer Mapping "

    }

 

Then in the view I use a standard tile as follows:


<StandardTile

              icon="sap-icon://{tiles>icon}"

              type="{tiles>type}"

              number="{tiles>number}"

              numberUnit="{tiles>numberUnit}"

              press="handleTilepress"

              title="{tiles>title}"

              info="{tiles>info}"

              infoState="{tiles>infoState}" />

So this means that each tile on the page launches the same event in the controller file. So finally in the controller I use the "id-tile" from the bindingContext to see on which tile was clicked and the value of the parameter is then assigned to the "navTo" command to do the actual routing.

 

handleTilepress: function(oEvent) {

            var selectedPage = oEvent.getSource().getBindingContext("tiles").getProperty("id-tile");

            var oRouter = sap.ui.core.UIComponent.getRouterFor(this);

            oRouter.navTo(selectedPage);

}

 

Thank you all for the reply's! I am very new to SAPUI5 development and I don't know if this is the best way of doing it but it seems to work fine for me :-)

 

Regards,

Nico


Viewing all articles
Browse latest Browse all 3354

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>