SAP UI5 XML View Tiles图标不起作用

时间:2014-10-16 12:28:14

标签: tiles sapui5

我有一个XML视图:

<mvc:View height="100%" xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" controllerName="my.own.controller">
<App>
    <Page showHeader="false" enableScrolling="false">
        <TileContainer id="container" tileDelete="handleTileDelete" tiles="{/TileCollection}">
            <StandardTile icon="sap-icon://{icon}" number="{number}" title="{title}" info="{info}" infoState="Success" />
        </TileContainer>
        <footer>
        </footer>
    </Page>
</App>

我有一个js:

function initialLoad(){

// create some dummy JSON data
var data = {
        "TileCollection" : [{
                                "icon":"history",
                                "number":"3",
                                "title" : "Project History",
                                "info": "click to view",
                                "infoState" : "Success"
                            }]
};

// instantiate the View
sap.ui.localResources("XMLViews");
var app = new sap.m.App({initialPage:"welcome"});
var myView  = sap.ui.xmlview({id:"welcome", viewName:"XMLViews/welcome"});
app.addPage(myView);

// create a Model and assign it to the View
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(data);
myView.setModel(oModel);

// put the View onto the screen
myView.placeAt("content");}

问题是图标没有显示出来。如果我在XML视图中硬编码:

icon="sap-icon://history"

然后图标正确显示。

我有一天遇到这个问题,如果你能给我一些提示我感激不尽!

谢谢!

1 个答案:

答案 0 :(得分:2)

将数据绑定到icon属性的方法不正确。它应该是这样的。

icon="{icon}"

而是在json中进行如下更改:

var data = {
        "TileCollection" : [{
                                "icon":"sap-icon://history", 
                                "number":"3",
                                "title" : "Project History",
                                "info": "click to view",
                                "infoState" : "Success"
                            }]
};

我认为这会奏效。