我无法获取绑定到RowRepeater元素的当前JSON模型元素.使用表和列表,我只需检索当前索引(或索引),并根据这些值,指向我的JSON模型中的匹配元素.
但是,RowRepeater元素没有当前索引属性.因为我觉得我应该能够直接检索当前元素,而不是间接地通过当前索引检索,是否有更好,统一的方法来检索当前元素?
型号示例代码:
var mydata = {
"data": [
{
"key": "67b895bf-8d89-11e3-94a7-0000005341de",
"name": "my 1st item"
},
{
"key": "7780de05-8d83-11e3-bec4-0000005341de",
"name": "my 2nd item"
}
]
};
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(dummydata);
sap.ui.getCore().setModel(oModel);
Run Code Online (Sandbox Code Playgroud)
RowRepeater的示例代码(我想在按下删除图标时检索当前的'键'):
var oRowRepeater = new sap.ui.commons.RowRepeater();
//create the template control that will be repeated and will display the data
var oRowTemplate = new sap.ui.commons.layout.MatrixLayout();
var matrixRow, matrixCell, control;
// main row
matrixRow = new sap.ui.commons.layout.MatrixLayoutRow();
//Text
control = new sap.ui.commons.TextView();
control.bindProperty("text","name");
//add content to cell, cell …Run Code Online (Sandbox Code Playgroud) 我有一个SAPUI5拆分应用程序,具有主视图和详细视图.
当我在侧栏中选择一个项目时,我将上下文传递给详细视图,让我们说产品1
onSelectProduct: function(evt){
sap.ui.getCore().getEventBus().publish("app", "refreshProductDetail", {context : evt.getSource( ).getBindingContext()});
},
Run Code Online (Sandbox Code Playgroud)
这会触发以下绑定上下文的函数:
refresh: function(channelId, eventId, data){
if (data && data.context) {
this.getView().setBindingContext(data.context);
}
},
Run Code Online (Sandbox Code Playgroud)
现在,当我执行像save这样的操作时,我想获取模型中产品1的当前数据.
但是,当我使用时
this.getView().getBindingContext().getModel()
Run Code Online (Sandbox Code Playgroud)
它返回包含所有产品的模型.我如何知道用户当前正在查看哪一个?
在SAP UI5中,当用户按下它时,我尝试获取绑定到表行的数据对象(在我的控制器中).我的视图在xml中定义,我的控制器当然在JS中.
我已经检查了如何在sap.m.table中获取行的内容,但它对我不起作用,或者缺少某些东西.
我的观点(相关部分):
<Panel>
<Table id="lineItemList" items="{
path: 'statusJobs>/jobs',
sorter: {
path: 'start',
descending: true
}
}">
<headerToolbar>
<!-- ... -->
</headerToolbar>
<columns>
<Column hAlign="Left" vAlign="Middle">
<Label text="Job" />
</Column>
<Column hAlign="Center" vAlign="Middle">
<Label text="Start" />
</Column>
<Column hAlign="Center" vAlign="Middle">
<Label text="End" />
</Column>
<Column hAlign="Right" vAlign="Middle">
<Label text="Success" />
</Column>
</columns>
<ColumnListItem
type="Navigation"
press=".handleLineItemPress"
>
<Text text="{statusJobs>job}" />
<Text text="{
path: 'statusJobs>start',
formatter:'util.Formatter.Date'}"
/>
<Text text="{
path: 'statusJobs>end',
formatter: 'util.Formatter.Date'}"
/>
<Text text="{statusJobs>status}"/>
</ColumnListItem>
</Table>
Run Code Online (Sandbox Code Playgroud)
这里的相关部分显然是: …
我想了解getEventBus().有人可以提供教程或最佳示例,我们可以在何处以及如何实施getEventBus().
我有一个包含一些磁贴的XMLView主页.这些切片是从JSON文件填充的.磁贴具有'title'属性,需要i18n数据绑定.
XML视图的一部分:
<TileContainer id="container" tiles="{/TileCollection}">
<StandardTile
icon="{icon}"
title="{title}"
press="onPress" />
</TileContainer>
Run Code Online (Sandbox Code Playgroud)
JSON文件:
{
"TileCollection" : [
{
"icon" : "sap-icon://document-text",
"title" : "{i18n>foo}"
},
... etc
Run Code Online (Sandbox Code Playgroud)
我完成数据绑定的旧方法直接在视图中title="{i18n>foo}".当然,现在我基本上有两层数据绑定,一个用于i18n的JSON,另一个用于获取JSON(获取i18n)的视图.
这也是我设置i18n模型的Component.js.
sap.ui.core.UIComponent.extend("MYAPP.Component", {
metadata: {
rootView : "MYAPP.view.Home", //points to the default view
config: {
resourceBundle: "i18n/messageBundle.properties"
},
... etc
init: function(){
sap.ui.core.UIComponent.prototype.init.apply(this, arguments);
var mConfig = this.getMetadata().getConfig();
var oRouter = this.getRouter();
this.RouteHandler = new sap.m.routing.RouteMatchedHandler(oRouter);
oRouter.register("router");
oRouter.initialize();
var sRootPath = jQuery.sap.getModulePath("MYAPP");
var i18nModel = new sap.ui.model.resource.ResourceModel({
bundleUrl : [sRootPath, mConfig.resourceBundle].join("/") …Run Code Online (Sandbox Code Playgroud) 我写这部分是为了用选择控制器绑定OData信息:
var countrItems = new sap.ui.core.ListItem();
countrItems.bindProperty("key", "Land1");
countrItems.bindProperty("text", "Landx");
var CountrSelect = this.byId("CountrySelect");
CountrSelect.setModel(oModelTriptab);
CountrSelect.bindItems("/Countries", countrItems);
Run Code Online (Sandbox Code Playgroud)
我想在绑定完成后执行一个动作(我想选择一些可以动态改变的默认值).
在OpenUI5 demokit 的1.5.2.3定义绑定路径部分中:
在聚合绑定的情况下,对于聚合的每个条目都存在上下文,或者可以使用setBindingContext方法为控件显式设置上下文.
在OpenUI5 demokit的1.5.3.3元素绑定部分中:
元素绑定允许将元素绑定到模型数据中的特定对象,这将创建绑定上下文并允许控件及其所有子元素之间的相对绑定.
在我看来,这两种技术实际上做同样的事情.它们都为控件创建绑定上下文,以便包含控件的绑定将相对于它进行解析.但它们之间的区别是什么?在什么情况下他们中的任何一个会发挥作用?
该setBindingContext不会在下面的代码工作:
https://jsbin.com/bigope/edit?html,output
但是,如果我改变oPanel.setBindingContext("/ nameinfo"); to oPanel.bindElement("/ nameinfo"); ,它有效,为什么?
我正在尝试使用SMP SDK 3.O PL3创建一个适用于iOS的Fiori客户端.在某些时候,它试图获取一个不存在的插件:通过npm获取插件"kapsel-plugin-inappbrowser"
$ cordova platform add ios --searchpath /Users/Pieter/SAP/MobileSDK3/KapselSDK/plugins
Adding ios project...
iOS project created with cordova-ios@3.9.1
Installing "cordova-plugin-camera" for ios
Installing "cordova-plugin-contacts" for ios
Installing "cordova-plugin-device" for ios
Installing "cordova-plugin-file" for ios
Installing "cordova-plugin-geolocation" for ios
Installing "cordova-plugin-media" for ios
Installing "cordova-plugin-media-capture" for ios
Installing "cordova-plugin-network-information" for ios
Installing "cordova-plugin-splashscreen" for ios
Installing "cordova-plugin-statusbar" for ios
Installing "cordova-plugin-whitelist" for ios
Installing "de.appplant.cordova.plugin.printer" for ios
Installing "kapsel-plugin-corelibs" for ios
Installing "kapsel-plugin-apppreferences" for ios
Installing "kapsel-plugin-attachmentviewer" for ios …Run Code Online (Sandbox Code Playgroud) 我对Odata主题很陌生,并尝试了解使用OData服务时的最佳实践场景.
Sceanrio 1:
我有一个复杂的应用程序,其中有几个来自远程Odata模型的EntitySets,它是从SAP Backend加载的.我可以读取数据并将其绑定到UI控件,这不是问题,但我感到困惑的是我如何/应该将数据写回到后端.
第一个假设Odata是单向绑定:
用户操作inputFields,dropdown,tables等,并使用createEntry()或setProperty()将所有数据写入Odata模型.对?或者我应该使用另一个JSONModel并收集所有用户更改?
问题:如何将Odata模型上的更改转移到后端?什么是最好的实践我已经阅读了有关批处理或拥有自己的服务的东西,并使用create()函数触发这个?有人可以提供一些提示或某种食谱.
Sceanrio 2:
双向绑定中的Odata?
这是如何运作的 ?OdataServices中后端必须提供哪些先决条件?我读了一些它是实验性的东西.
你看我有点困惑.
我已经尝试阅读上面的SAPUI5文档,但我无法清楚地了解它的用法.此外之间有什么区别sap.ui.localResources()和jQuery.sap.registerModulePath()以及何时使用什么呢?
如果有人可以用一个简单的例子来解释它将会非常有用.我们还可以jQuery.sap.registerModulePath()用来加载mockData吗?