[英]SAPUI5 How to get object from context by value?
我在JS視圖中構建一個SAPUI5應用程序,我有一個JSON模型,如下所示
{
"Categories": [
{
"name":"L1 Category One",
"icon":"sap-icon://home",
"description":"Sample Description",
"sub-categories":{[
{
"name":"L2 Category One",
"icon":"sap-icon://action",
"description":"Sample Description",
}
]}
}
{
"name":"L1 Category Two",
"icon":"sap-icon://action",
"description":"Sample Description"
}
{
"name":"L1 Category Three",
"icon":"sap-icon://doctor",
"description":"Sample Description"
}
{
"name":"L1 Category Four",
"icon":"sap-icon://cart",
"description":"Sample Description"
}
]
}
我正在使用此模型構建類似於類別導航的圖塊,如下所示
var oSampleLayout = new sap.ui.layout.HorizontalLayout("cats-layout");
oSampleLayout.setModel(oModel);
var ooCategoryIcon = new sap.ui.core.Icon();
ooCategoryIcon.setSrc("{icon}");
ooCategoryIcon.addStyleClass("category-icon");
var ooCategoryName = new sap.ui.commons.TextView();
ooCategoryName.setText("{name}");
var oOtherTemplate = new sap.ui.commons.layout.VerticalLayout("",{content:[ooCategoryIcon,ooCategoryName]});
oOtherTemplate.addStyleClass("cat");
oOtherTemplate.attachBrowserEvent('click',soidPress);
oSampleLayout.bindAggregation("content",{path:"/Categories",template:oOtherTemplate});
oSampleLayout.placeAt('other-content');
單擊時,我正在獲取綁定上下文並調用一種方法來渲染子類別,在將上下文傳遞給render方法的過程中,但是我被困在渲染子類別中,我該怎么做? 有任何想法嗎
我已經將context.oModel設置為子類別的模型,並使用上下文路徑將元素綁定為
oxLayout.bindElement(oContext.sPath);
這使我可以綁定上下文路徑中的特定元素,並再次使用聚合來形成子類別。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.