Valuehelp函数不适用于OData绑定

2020-08-18 15:56发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)我已经开发了一个项目,其中包含v...

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

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


我已经开发了一个项目,其中包含valuehelp函数,使用Odata而不是JSON,在显示表时出现错误,而不显示数据列和行。

选择一行后,它显示所有行值,但不显示项目值。

我的控制器代码:

 onInit:函数(){


 this.getRouter()。attachRoutePatternMatched(this.onRouteMatched,this);

//值帮助
 this._oMultiInput = this.getView()。byId(" multiInput");
 this._oMultiInput.setTokens(this._getDefaultTokens());
 this._oMultiInput.addValidator(this._onMultiInputValidate);



 this.oColModel =新的JSONModel(sap.ui.require.toUrl(" myNamespace")+"/columnsModel.json");
 var oHelpModell = new sap.ui.model.json.JSONModel();

 var oModell = new sap.ui.model.odata.v2.ODataModel(" http://MYSERVICENAME/");
 oHelpModell.loadData(oModell,true);
 oHelpModell.setData()
/* var DataLoaded = oModell.read("/img/MYENTITYNAME",
 {成功:功能(响应){
                //响应将重新执行请求
 console.log(response.results);
 MessageToast.show("成功");
 },错误:function(e){
 MessageToast.show("失败");}
 });
 */
 var oDataLoad = oModell.setProperty("/img/MYENTITYNAME");
 this.getView()。setModel(oDataLoad);


 },


 onValueHelpRequested:function(){
 var aCols = this.oColModel.getData()。cols;
 this._oBasicSearchField = new SearchField({
 showSearchButton:否
 });

 this._oValueHelpDialog = sap.ui.xmlfragment(" myNamespace.fragment.ValueHelpDialogInputSuggestions",this);
 this.getView()。addDependent(this._oValueHelpDialog);

 this._oValueHelpDialog.setRangeKeyFields([{
 标签:"材料编号",
 密钥:"材料编号",
 类型:"字符串",
 typeInstance:new typeString({},{
 最大长度:7
 })
 }]);

 this._oValueHelpDialog.getFilterBar()。setBasicSearch(this._oBasicSearchField);

 this._oValueHelpDialog.getTableAsync()。then(function(oTable){

 oTable.setModel(this.oDataLoad);
 oTable.setModel(this.oColModel," columns");

 if(oTable.bindRows){
 oTable.bindAggregation(" rows","/img/MYENTITYNAME");

 }

 如果(oTable.bindItems){
 oTable.bindAggregation(" items","/img/MYENTITYNAME",函数(){
 返回新的ColumnListItem({
 单元格:aCols.map(function(column){
 返回新的Label({text:" {" + column.template +"}"});
 })
 });
 });
 }

 this._oValueHelpDialog.update();
 } .bind(this));
 this._oValueHelpDialog.setTokens(this._oMultiInput.getTokens());
 this._oValueHelpDialog.open();
 },

 onValueHelpOkPress:函数(oEvent){
 var aTokens = oEvent.getParameter(" tokens");
 this._oMultiInput.setTokens(aTokens);
 this._oValueHelpDialog.close();
 },

 onValueHelpCancelPress:函数(){
 this._oValueHelpDialog.close();
 },


 onValueHelpAfterClose:function(){
 this._oValueHelpDialog.destroy();
 },

 onFilterBarSearch:函数(oEvent){
 var sSearchQuery = this._oBasicSearchField.getValue(),
 aSelectionSet = oEvent.getParameter(" selectionSet");
 var aFilters = aSelectionSet.reduce(function(aResult,oControl){
 如果(oControl.getValue()){
 aResult.push(new Filter({
 路径:oControl.getName(),
 运算子:FilterOperator。包含,
 value1:oControl.getValue()
 }));
 }


 返回结果;
 },[]);


 aFilters.push(new Filter({
 过滤器:[
 新的Filter({路径:" Matnr",运算符:FilterOperator。包含,值1:sSearchQuery}),
 新的Filter({路径:" Maktx",运算符:FilterOperator。包含,值1:sSearchQuery})
 ],
 和:false
 }));


 this._filterTable(new Filter({
 过滤器:aFilters,
 和:正确
 }));
 },

 _filterTable:函数(oFilter){
 var oValueHelpDialog = this._oValueHelpDialog;


 oValueHelpDialog.getTableAsync()。then(function(oTable){
 如果(oTable.bindRows){
 oTable.getBinding(" rows")。filter(oFilter);
 }


 如果(oTable.bindItems){
 oTable.getBinding(" items")。filter(oFilter);
 }


 oValueHelpDialog.update();
 });
 },

 _onMultiInputValidate:function(oArgs){
 如果(oArgs.suggestionObject){
 var oObject = oArgs.suggestionObject.getBindingContext()。getObject(),
 oToken = new Token();


 oToken.setKey(oObject.ProductId);
 oToken.setText(oObject.Name +"(" + oObject.ProductId +")");
 }


 返回null;
 },

 _getDefaultTokens:function(){
 var ValueHelpRangeOperation = compLibrary.valuehelpdialog.ValueHelpRangeOperation;
 var oToken1 = new Token({
 键:" 100-100",
 文字:" hjjggjhggj"
 });


 var oToken2 =新令牌({
 键:" range_0",
 文字:" 100-100"
 })。数据范围", {
 "排除":是的,
 " operation":ValueHelpRangeOperation.EQ,
 " keyField":"材料ID",
 " value1":" 100023",
 " value2":"材料成本"
 });


 返回[oToken1,oToken2];
 },
 

MyViewcode

 
 
 
 
 <!-<标签文本=" Products" labelFor =" multiInput"/>->
 
 
 <栏目>
 
 
 
 <单元格>
 
 


 
 
 
 
 

 

MyFragment

 

 

 
 
 
 
 
 
 
 


 
 
 
 
 
 
 
 

 

 
 
 Myjson.json
 {
 " cols":[
 {
 " label":"材料编号",
 " template":" Matnr"
 },
 {
 " label":"描述",
 " template":" Maktx"
 }
 ]
 }
 

任何人都可以帮助我解决此错误

谢谢。

valuehelp-err.jpg (61.9 kB)