SAPUI5变体管理-未保存默认值和公共

2020-09-09 14:13发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


你好

我正在使用正在保存的变体管理,但选中时不使用"默认"或"公共"。 这是我的代码:

xml:

控制器:

//变式管理_getAllVariants:函数(fnCallBack){var oPersonalizationVariantSet = {},aExistingVariants = [],aVariantKeysAndNames = []; //获取shell的个性化服务this._oPersonalizationService = sap.ushell.Container.getService(" Personalization"); //从个性化服务中获取容器this._oPersonalizationContainer = this._oPersonalizationService.getPersonalizationContainer(" MyVariantContainer"); this._oPersonalizationContainer.fail(function(){fnCallBack(aExistingVariants);}); this._oPersonalizationContainer.done(function(oPersonalizationContainer){//从容器中检索vaariantset if(!(oPersonalizationContainer.containsVariantSet(" SOStatVariants"))){oPersonalizationContainer.addVariantSet(" SOStatVariantization" Ptain。 "); aVariantKeysAndNames = oPersonalizationVariantSet.getVariantNamesAndKeys();//为现有变体创建对象以绑定varinatmanagement控制,以查看(aVariantKeysAndNames中的var key){if((aVariantKeysAndNames.hasOwnProtty(Key)){Item VariantKey = aVariantKeysAndNames [key]; oVariantItemObject.VariantName = key; aExistingVariants.push(oVariantItemObject);}} fnCallBack(aExistingVariants);} .bind(this)); },onSaveAsVariant:函数(oEvent){var SelectedFilterData = this.getView()。getModel(" filterViewModel")。getData(); var TableFilterData = this.getOwnerComponent()。getModel(" variantTableColumnModel")。getData(); //this.getView()。byId(" idResultTable")._ getVisibleColumns(); console.log(SelectedFilterData); ////this.getOwnerComponent()。saveVariant(this._oPersonalizationContainer,oEvent.getParameter(" name"),SelectedFilterData,function(){////执行所需的操作//} .bind(this)); this.saveVariant(oEvent.getParameter(" name"),SelectedFilterData,TableFilterData,function(){//执行所需的操作console.log('here!');} .bind(this)); },/** *此方法用于保存变量* @param {String} sVariantName-变量名* @param {Object} oFilterData-过滤数据对象-> JSON中的合并过滤器* @param {Function} fnCallBack-调用 带有变体数组的back函数*/saveVariant:function(sVariantName,oFilterData,oTableData,fnCallBack){//将变体保存在个性化容器console.log(oFilterData); this._oPersonalizationContainer.fail(function(){//失败时回调函数fnCallBack(false);}); this._oPersonalizationContainer.done(function(oPersonalizationContainer){var oPersonalizationVariantSet = {},oVariant = {},sVariantKey ="";//检查当前变量集是否存在,如果不存在,则将新变量集添加到容器中,如果( !(oPersonalizationContainer.containsVariantSet(" SOStatVariants"))){oPersonalizationContainer.addVariantSet(" SOStatVariants");}//获取变量集oPersonalizationVariantSet = oPersonalizationContainer.getVariantSet(" SOStatVariants" add)如果存在,或者//变体sVariantKey = oPersonalizationVariantSet.getVariantKeyByName(sVariantName); if(sVariantKey){oVariant = oPersonalizationVariantSet.getVariant(sVariantKey);} else {oVariant = oPersonalizationVariantSet(){Value,"();( JSON.stringify(oFilterData));} if(oTableData){oVariant.setItemValue(" Table",JSON.stringify(oTableData));} oPersonalizationContainer.save()。fail(function(){//调用回调fn wi 错误的fnCallBack(false); })。done(function(){//使用true fnCallBack(true);} .bind(this))进行回调 } .bind(this)); },onManageVariant:函数(oEvent){var aDeletedVariants = oEvent.mParameters.deleted,aRenamedVariants = oEvent.mParameters.renamed,sNewDefaultVariantKey = oEvent.mParameters.def if(aDeletedVariants.length> 0){this.deleteVariants(aDeletedVariants,function(bDeleted){//如果bDeleted为true,则删除成功)); } if(aRenamedVariants.length> 0){//从变体集中获取变体,并在个性化变体集中将其重命名,然后保存。 }},deleteVariants:函数(aVariantKeys,fnCallback){var oPersonalizationVariantSet = {}; this._oPersonalizationContainer.fail(function(){//处理失败的情况}); this._oPersonalizationContainer.done(function(oPersonalizationContainer){if(!(oPersonalizationContainer.containsVariantSet(" SOStatVariants"))){oPersonalizationContainer.addVariantSet(" SOStatVariants");} oPersonalizationVariantSet(O; iCount = 0; iCount

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


你好

我正在使用正在保存的变体管理,但选中时不使用"默认"或"公共"。 这是我的代码:

xml:

控制器:

//变式管理_getAllVariants:函数(fnCallBack){var oPersonalizationVariantSet = {},aExistingVariants = [],aVariantKeysAndNames = []; //获取shell的个性化服务this._oPersonalizationService = sap.ushell.Container.getService(" Personalization"); //从个性化服务中获取容器this._oPersonalizationContainer = this._oPersonalizationService.getPersonalizationContainer(" MyVariantContainer"); this._oPersonalizationContainer.fail(function(){fnCallBack(aExistingVariants);}); this._oPersonalizationContainer.done(function(oPersonalizationContainer){//从容器中检索vaariantset if(!(oPersonalizationContainer.containsVariantSet(" SOStatVariants"))){oPersonalizationContainer.addVariantSet(" SOStatVariantization" Ptain。 "); aVariantKeysAndNames = oPersonalizationVariantSet.getVariantNamesAndKeys();//为现有变体创建对象以绑定varinatmanagement控制,以查看(aVariantKeysAndNames中的var key){if((aVariantKeysAndNames.hasOwnProtty(Key)){Item VariantKey = aVariantKeysAndNames [key]; oVariantItemObject.VariantName = key; aExistingVariants.push(oVariantItemObject);}} fnCallBack(aExistingVariants);} .bind(this)); },onSaveAsVariant:函数(oEvent){var SelectedFilterData = this.getView()。getModel(" filterViewModel")。getData(); var TableFilterData = this.getOwnerComponent()。getModel(" variantTableColumnModel")。getData(); //this.getView()。byId(" idResultTable")._ getVisibleColumns(); console.log(SelectedFilterData); ////this.getOwnerComponent()。saveVariant(this._oPersonalizationContainer,oEvent.getParameter(" name"),SelectedFilterData,function(){////执行所需的操作//} .bind(this)); this.saveVariant(oEvent.getParameter(" name"),SelectedFilterData,TableFilterData,function(){//执行所需的操作console.log('here!');} .bind(this)); },/** *此方法用于保存变量* @param {String} sVariantName-变量名* @param {Object} oFilterData-过滤数据对象-> JSON中的合并过滤器* @param {Function} fnCallBack-调用 带有变体数组的back函数*/saveVariant:function(sVariantName,oFilterData,oTableData,fnCallBack){//将变体保存在个性化容器console.log(oFilterData); this._oPersonalizationContainer.fail(function(){//失败时回调函数fnCallBack(false);}); this._oPersonalizationContainer.done(function(oPersonalizationContainer){var oPersonalizationVariantSet = {},oVariant = {},sVariantKey ="";//检查当前变量集是否存在,如果不存在,则将新变量集添加到容器中,如果( !(oPersonalizationContainer.containsVariantSet(" SOStatVariants"))){oPersonalizationContainer.addVariantSet(" SOStatVariants");}//获取变量集oPersonalizationVariantSet = oPersonalizationContainer.getVariantSet(" SOStatVariants" add)如果存在,或者//变体sVariantKey = oPersonalizationVariantSet.getVariantKeyByName(sVariantName); if(sVariantKey){oVariant = oPersonalizationVariantSet.getVariant(sVariantKey);} else {oVariant = oPersonalizationVariantSet(){Value,"();( JSON.stringify(oFilterData));} if(oTableData){oVariant.setItemValue(" Table",JSON.stringify(oTableData));} oPersonalizationContainer.save()。fail(function(){//调用回调fn wi 错误的fnCallBack(false); })。done(function(){//使用true fnCallBack(true);} .bind(this))进行回调 } .bind(this)); },onManageVariant:函数(oEvent){var aDeletedVariants = oEvent.mParameters.deleted,aRenamedVariants = oEvent.mParameters.renamed,sNewDefaultVariantKey = oEvent.mParameters.def if(aDeletedVariants.length> 0){this.deleteVariants(aDeletedVariants,function(bDeleted){//如果bDeleted为true,则删除成功)); } if(aRenamedVariants.length> 0){//从变体集中获取变体,并在个性化变体集中将其重命名,然后保存。 }},deleteVariants:函数(aVariantKeys,fnCallback){var oPersonalizationVariantSet = {}; this._oPersonalizationContainer.fail(function(){//处理失败的情况}); this._oPersonalizationContainer.done(function(oPersonalizationContainer){if(!(oPersonalizationContainer.containsVariantSet(" SOStatVariants"))){oPersonalizationContainer.addVariantSet(" SOStatVariants");} oPersonalizationVariantSet(O; iCount = 0; iCount

付费偷看设置
发送
5条回答
CPLASF-自律
1楼-- · 2020-09-09 14:54
 VIEW:

 
 
 
 
 


 控制器:


//变体管理
 _getAllVariants:函数(fnCallBack){
 var oPersonalizationVariantSet = {},
 aExistingVariants = [],
 aVariantKeysAndNames = [];
//获取shell的个性化服务
 this._oPersonalizationService = sap.ushell.Container.getService(" Personalization");


//从个性化服务中获取容器
 this._oPersonalizationContainer = this._oPersonalizationService.getPersonalizationContainer(" MyVariantContainer");
 this._oPersonalizationContainer.fail(function(){
 fnCallBack(aExistingVariants);
 });
 this._oPersonalizationContainer.done(function(oPersonalizationContainer){
//从容器中获取vaariantset
 如果(!(oPersonalizationContainer.containsVariantSet(" SOStatVariants"))){
 oPersonalizationContainer.addVariantSet(" SOStatVariants");
 }
 oPersonalizationVariantSet = oPersonalizationContainer.getVariantSet(" SOStatVariants");


 aVariantKeysAndNames = oPersonalizationVariantSet.getVariantNamesAndKeys();
//为现有变体创建对象以在视图中绑定varinatmanagement控件
 为(aVariantKeysAndNames中的var键){
 如果(aVariantKeysAndNames.hasOwnProperty(key)){
 var oVariantItemObject = {};
 oVariantItemObject.VariantKey = aVariantKeysAndNames [key];
 oVariantItemObject.VariantName =键;
 aExistingVariants.push(oVariantItemObject);
 }
 }
 fnCallBack(aExistingVariants);
 } .bind(this));
 },
 onSaveAsVariant:函数(oEvent){
 var SelectedFilterData = this.getView()。getModel(" filterViewModel")。getData();
 var TableFilterData = this.getOwnerComponent()。getModel(" variantTableColumnModel")。getData(); //this.getView()。byId(" idResultTable")._ getVisibleColumns();

 this.saveVariant(oEvent.getParameter(" name"),SelectedFilterData,TableFilterData,function(){
//执行必要的动作
 } .bind(this));
 },


/**
 *此方法是保存变体
 * @param {String} sVariantName-变体名称
 * @param {Object} oFilterData-过滤数据对象-> JSON中的合并过滤器
 * @param {Function} fnCallBack-带有变体数组的回调函数
 */
 saveVariant:函数(sVariantName,oFilterData,oTableData,fnCallBack){
//将变体保存在个性化容器中
 console.log(oFilterData);
 this._oPersonalizationContainer.fail(function(){
//失败时回调函数
 fnCallBack(false);
 });
 this._oPersonalizationContainer.done(function(oPersonalizationContainer){
 var oPersonalizationVariantSet = {},
 oVariant = {},
 sVariantKey ="";
//检查当前变量集是否存在,如果不存在,则将新变量集添加到容器中
 如果(!(oPersonalizationContainer.containsVariantSet(" SOStatVariants"))){
 oPersonalizationContainer.addVariantSet(" SOStatVariants");
 }
//获取变量集
 oPersonalizationVariantSet = oPersonalizationContainer.getVariantSet(" SOStatVariants");
//获取变体是否存在或添加新变体
 sVariantKey = oPersonalizationVariantSet.getVariantKeyByName(sVariantName);
 如果(sVariantKey){
 oVariant = oPersonalizationVariantSet.getVariant(sVariantKey);
 }其他{
 oVariant = oPersonalizationVariantSet.addVariant(sVariantName);
 }
 如果(oFilterData){
 oVariant.setItemValue(" Filter",JSON.stringify(oFilterData));
 }
 如果(oTableData){
 oVariant.setItemValue(" Table",JSON.stringify(oTableData));
 }
 oPersonalizationContainer.save()。fail(function(){
//用false调用回调fn
 fnCallBack(false);
 })。done(function(){
//用true回调
 fnCallBack(true);
 } .bind(this));
 } .bind(this));
 },
 onManageVariant:函数(oEvent){
 var aDeletedVariants = oEvent.mParameters.deleted,
 aRenamedVariants = oEvent.mParameters.renamed,
 sNewDefaultVariantKey = oEvent.mParameters.def;
 如果(aDeletedVariants.length> 0){
 this.deleteVariants(aDeletedVariants,function(bDeleted){
//如果bDeleted为true,则删除成功
 });
 }
 如果(aRenamedVariants.length> 0){
//从变量集获取变量,然后在个性化变量集中将其重命名,然后保存。
 }
 },


 deleteVariants:函数(aVariantKeys,fnCallback){
 var oPersonalizationVariantSet = {};
 this._oPersonalizationContainer.fail(function(){
//处理失败案例
 });
 this._oPersonalizationContainer.done(function(oPersonalizationContainer){
 如果(!(oPersonalizationContainer.containsVariantSet(" SOStatVariants"))){
 oPersonalizationContainer.addVariantSet(" SOStatVariants");
 }
 oPersonalizationVariantSet = oPersonalizationContainer.getVariantSet(" SOStatVariants");
 for(var iCount = 0; iCount                                                                     
粗暴的香蕉
2楼-- · 2020-09-09 15:00

代码不可读,您应该将其输入代码,工具栏上的"代码"选项上单击并在其中插入代码

哎,真难
3楼-- · 2020-09-09 14:45

嗨,

对于智能控件,除了确认需要变体管理之外,您无需执行任何其他操作。 不幸的是,我不能在这里使用智能控件。

谢谢

Eric

软件心理学工程师
4楼-- · 2020-09-09 14:48

嗨,

我遵循了这种方法,并且能够保存,选择和删除变体。 但是我不知道如何设置为默认变量? 。 varinatSetcontroller有什么可用的方法吗?

蓋茨
5楼-- · 2020-09-09 14:35

为什么要处理该变体?

在我的内存中,这都是由sap完成的,您不是 必须做任何事情。

一周热门 更多>