[英]SAPUI5 How to get object from context by value?
I'm building a SAPUI5 application in JS view i have a JSON model as follows 我在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"
}
]
}
I'm building a tile like category navigation using this model as follows 我正在使用此模型构建类似于类别导航的图块,如下所示
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');
on click I'm getting the binding context and calling a method to render the subcategories where I'm passing the context to the render method but I'm stuck in getting the subcategories rendered How can i do that? 单击时,我正在获取绑定上下文并调用一种方法来渲染子类别,在将上下文传递给render方法的过程中,但是我被困在渲染子类别中,我该怎么做? Any Ideas
有任何想法吗
I've set the context.oModel as the model to the sub categories and have bound the element using the context path as 我已经将context.oModel设置为子类别的模型,并使用上下文路径将元素绑定为
oxLayout.bindElement(oContext.sPath);
this allowed me to bind the particular element from the contexts path and use the aggregation again forming the sub-categories. 这使我可以绑定上下文路径中的特定元素,并再次使用聚合来形成子类别。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.