点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)嗨, 我需要一些帮助,我在获取...
点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)嗨, 我需要一些帮助,我在获取...
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
嗨,
我需要一些帮助,我在获取片段视图以读取i18n文件以在标签上显示文本时遇到问题。
我的项目最初是用SAP Build创建的,在这里我为表启用了排序/过滤/分组功能,这会自动为视图/控制器片段生成代码。
我尝试添加以下行:this.getView()。addDependent(oDialog); 创建从主视图到片段的依赖关系,但这似乎会进一步产生问题...
谁能告诉我在哪里/如何正确创建依赖关系?
这是过滤器视图片段的控制器代码...
_onFilterButtonPress:函数(oEvent){ this.mSettingsDialogs = this.mSettingsDialogs || {}; var sSourceId = oEvent.getSource()。getId(); var oDialog = this.mSettingsDialogs [" FilterDialog"]; var ConfirmHandler = function(oConfirmEvent){ var self = this; var sFilterString = oConfirmEvent.getParameter('filterString'); var oBindingData = {}; /*过滤*/ oBindingData.filters = []; //将应用于集合的过滤器列表 var oFilter; var vValueLT,vValueGT; vValueLT = oDialog.getModel()。getProperty("/img/dateRaised/vValueLT"); vValueGT = oDialog.getModel()。getProperty("/img/dateRaised/vValueGT"); 如果(vValueLT!=="" || vValueGT!==""){ oFilter = this.getCustomFilter(" dateRaised",vValueLT,vValueGT); oBindingData.filters.push(oFilter); sFilterString = sFilterString吗? sFilterString +',':'过滤依据:'; sFilterString + = this.getCustomFilterString(true," Date Raised",oFilter.sOperator,vValueLT,vValueGT); } //简单的过滤器(字符串) var mSimpleFilters = {}, sKey; for(oConfirmEvent.getParameter(" filterKeys")中的sKey){ var aSplit = sKey.split(" ___"); var sPath = aSplit [1]; var sValue1 = aSplit [2]; var oFilterInfo = new sap.ui.model.Filter(sPath," EQ",sValue1); //为每个路径创建一个过滤器映射 如果(!mSimpleFilters [sPath]){ mSimpleFilters [sPath] = [oFilterInfo]; }其他{ mSimpleFilters [sPath] .push(oFilterInfo); } } for(mSimpleFilters中的var路径){ //同一路径上的所有过滤器都用OR组合 oBindingData.filters.push(new sap.ui.model.Filter(mSimpleFilters [path],false)); } aCollections.forEach(function(oCollectionItem){ var oCollection = self.getView()。byId(oCollectionItem.id); var oBindingInfo = oCollection.getBindingInfo(oCollectionItem.aggregation); var oBindingOptions = this.updateBindingOptions(oCollectionItem.id,oBindingData,sSourceId); 如果(oBindingInfo.model ===" kpiModel"){ oCollection.getObjectBinding()。refresh(); }其他{ oCollection.bindAggregation(oCollectionItem.aggregation,{ 型号:oBindingInfo.model, 路径:oBindingInfo.path, 参数:oBindingInfo.parameters, 模板:oBindingInfo.template, templateShareable:true, 排序器:oBindingOptions.sorters, 过滤器:oBindingOptions.filters }); } //必要时显示过滤字符串 if(typeof oCollection.getInfoToolbar ===" function"){ var oToolBar = oCollection.getInfoToolbar(); 如果(oToolBar && oToolBar.getContent()。length === 1){ oToolBar.setVisible(!! sFilterString); oToolBar.getContent()[0] .setText(sFilterString); } } }, 这个); } .bind(this); 函数resetFiltersHandler(){ oDialog.getModel()。setProperty("/img/dateRaised/vValueLT",""); oDialog.getModel()。setProperty("/img/dateRaised/vValueGT",""); } 函数updateDialogData(filters){ var mParams = { 上下文:oReferenceCollection.getBindingContext(), 成功:function(oData){ var oJsonModelDialogData = {}; //遍历每个实体 oData.results.forEach(function(oEntity){ //在地图中添加不同的属性 for(oEntity中的var oKey){ 如果(!oJsonModelDialogData [oKey]){ oJsonModelDialogData [oKey] = [oEntity [oKey]]; }否则,如果(oJsonModelDialogData [oKey] .indexOf(oEntity [oKey])=== -1){ oJsonModelDialogData [oKey] .push(oEntity [oKey]); } } }); var oDialogModel = oDialog.getModel(); oJsonModelDialogData [" dateRaised"] = { vValueLT:(oDialogModel && oDialogModel.getProperty("/img/dateRaised"))? oDialogModel.getProperty("/img/dateRaised/vValueLT"):"", vValueGT:(oDialogModel && oDialogModel.getProperty("/img/dateRaised"))? oDialogModel.getProperty("/img/dateRaised/vValueGT"):"" }; 如果(!oDialogModel){ oDialogModel = new sap.ui.model.json.JSONModel(); oDialog.setModel(oDialogModel); } oDialogModel.setData(oJsonModelDialogData); oDialog.open(); } }; var sPath; var sModelName = oReferenceCollection.getBindingInfo(aCollections [0] .aggregation).model; //在图表的KPI模式下,getBindingInfo将返回本地JSONModel 如果(sModelName ===" kpiModel"){ sPath = oReferenceCollection.getObjectBinding()。getPath(); }其他{ sPath = oReferenceCollection.getBindingInfo(aCollections [0] .aggregation).path; } mParams.filters =过滤器; oModel.read(sPath,mParams); } 如果(!oDialog){ oDialog = sap.ui.xmlfragment({ fragmentName:" dsn.RiskRegister.view.FilterDialog" }, 这个); oDialog.attachEvent(" confirm",ConfirmHandler); oDialog.attachEvent(" resetFilters",resetFiltersHandler); this.mSettingsDialogs [" FilterDialog"] = oDialog; } var aCollections = []; aCollections.push({ id:" riskTable", 聚合:"项目" }); var oReferenceCollection = this.getView()。byId(aCollections [0] .id); var oSourceBindingContext = oReferenceCollection.getBindingContext(); var oModel = oSourceBindingContext吗? oSourceBindingContext.getModel():this.getView()。getModel(); //切换紧凑样式 jQuery.sap.syncStyleClass(" sapUiSizeCompact",this.getView(),oDialog); var designTimeFilters = this.mBindingOptions && this.mBindingOptions [aCollections [0] .id] && this.mBindingOptions [aCollections [0] .id] .filters && this.mBindingOptions [aCollections [0] .id] .filters [undefined]; updateDialogData(designTimeFilters); },
问题到底是什么?
至少您可以从视图中获取模型,然后将Model设置为片段。
一周热门 更多>