简体   繁体   English

SAPUI5使用来自XMII的OData填充SmartTable

[英]SAPUI5 Filling SmartTable with OData from XMII

I'm currently trying to fill a Smart Table (xml view) with OData from our MII server. 我目前正在尝试使用MII服务器中的OData填充智能表(xml视图)。 I keep getting the following errors: 我不断收到以下错误:

Error: resource PATH /Component-changes.json could not be loaded from ./Component-changes.json. 错误:无法从./Component-changes.json加载资源PATH /Component-changes.json。 Check for 'file not found' or parse errors. 检查“找不到文件”或解析错误。 Reason: Not Found - 'getChanges' failed: - 原因:找不到-'getChanges'失败:-

This is my Main.controller.js: 这是我的Main.controller.js:

sap.ui.controller("PATH.view.Main", {

/**
* Called when a controller is instantiated and its View controls (if available) are already created.
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
* @memberOf sapui5.Main
*/
onInit: function() {
    var oModel, oView;
    this.oUpdateFinishedDeferred = jQuery.Deferred();
    this.getView().byId("main").attachEventOnce("updateFinished", function(){
        this.oUpdateFinishedDeferred.resolve();
    }, this);
         sap.ui.core.UIComponent.getRouterFor(this).attachRouteMatched(this.onRouteMatched , this);

    var oModel, oView;
    oModel = new sap.ui.model.odata.ODataModel("http://server:port/XMII/IlluminatorOData/QueryTemplate?QueryTemplate=MessageMonitor%2FTemplates%2FQuery%2FMIILogDetailsQry&Content-Type=text%2Fxml", {annotationURI: "/XMII/IlluminatorOData/$metadata"});

    jQuery.sap.log.error(oModel.getMetaModel());
    oModel.setCountSupported(false);
    var oTable = this.getView().byId("oTable");
    oTable.setEntitySet("Messages");
    oTable.setModel(oModel);
    oView = this.getView();
    oView.setModel(oModel);
    oTable.rebindTable();
},
onRouteMatched : function(oEvent) {
     var oList = this.getView().byId("main");
     var sName = oEvent.getParameter("name");
     var oArguments = oEvent.getParameter("arguments");
    // Wait for the list to be loaded once
     jQuery.when(this.oUpdateFinishedDeferred).then(jQuery.proxy(function() {
     var aItems;
         // On the empty hash select the first item
         if (sName === "main") {
             //this.selectDetail();
         }
         // Try to select the item in the list
         if (sName === "product") {
             aItems = oList.getItems();
             for (var i = 0; i < aItems.length; i++) {
                 if (aItems[i].getBindingContext().getPath() === "/" +
                         oArguments.product) {
                     oList.setSelectedItem(aItems[i], true);
                     break;
                 }
             }
         }
     }, this));
},
});

I'm developing on the server itself so I have no issues with the CORS errors I would get otherwise. 我在服务器本身上进行开发,因此我不会遇到CORS错误,否则会出现问题。

My Main.view.xml: 我的Main.view.xml:

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:smartFilterBar="sap.ui.comp.smartfilterbar" xmlns:smartTable="sap.ui.comp.smarttable" controllerName="PATH.view.Main" height="100%" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1">
<Page id="main" title="{i18n>PageTitle}" showNavButton="false">
<Toolbar></Toolbar>
    <content>
    <smartFilterBar:SmartFilterBar id="smartFilterBar" entityType="Messages" persistencyKey="SmartFilter_Explored">
    <smartFilterBar:controlConfiguration>            
      <smartFilterBar:ControlConfiguration key="CATEGORY">
      <smartFilterBar:defaultFilterValues>
          <smartFilterBar:SelectOption low="i">
          </smartFilterBar:SelectOption>
        </smartFilterBar:defaultFilterValues>
      </smartFilterBar:ControlConfiguration>          
      <smartFilterBar:ControlConfiguration key="DATETIME">
        <smartFilterBar:defaultFilterValues>
            <smartFilterBar:SelectOption low="2014">
            </smartFilterBar:SelectOption>
          </smartFilterBar:defaultFilterValues>
        </smartFilterBar:ControlConfiguration>
      </smartFilterBar:controlConfiguration>          
    </smartFilterBar:SmartFilterBar>

        <smartTable:SmartTable id="oTable" entitySet="Messages" 
        smartFilterId="smartFilterBar" tableType="Table" 
        useExportToExcel="false" useVariantManagement="false" 
        useTablePersonalisation="false" header="Messages" 
        showRowCount="false" 
        persistencyKey="SmartTableAnalytical_Explored" 
        enableAutoBinding="true" />
    </content>
</Page>

My Component.js, index.html and MyRouter.js are setup according to the SAP Hana step by step guide for your first application. 我的Component.js,index.html和MyRouter.js是根据SAP Hana分步指南为您的第一个应用程序设置的。

I'm completely clueless on what the issue might be. 我对这个问题可能是一无所知。

Thanks in advance. 提前致谢。

The file component-changes.json is read for Variant Management but this should not prevent the data in smart table from loading. 读取文件component-changes.json以进行变体管理,但这不应阻止加载智能表中的数据。 And since you have set enableAutoBinding does the system make a call to your Service/Messages? 既然已经设置了enableAutoBinding,系统是否会调用您的服务/消息?

I've ended up doing something entirely else due to the fact the metadata wasn't the right data I needed for the Smart-Table. 由于元数据不是智能表所需的正确数据,我最终做了其他事情。 Thanks for the answers to the question. 感谢您对问题的回答。

I've created a default table in my controller, which I filled with the columns I needed and wanted. 我在控制器中创建了一个默认表,其中填充了我需要和想要的列。 And I've bound my rows to the columns. 我将行绑定到列。

var oTable = new sap.ui.table.Table();
oTable.addColumn(new sap.ui.table.Column({label: "{i18n>Category}", editable: false,
        template: new sap.ui.commons.TextField( {
            value: {
                path: "CATEGORY",
                formatter: sap.ui.demo.table.util.Formatter.label,
            },
            editable : false,
        }), sortProperty: "Category" }));
 // more addColumn lines...
oTable.setSelectionMode(sap.ui.table.SelectionMode.Single); // Single select mode.
oTable.bindRows({ // bind the rows to the odata model.
    path: '/Rowset(QueryTemplate=\'MessageMonitor/Templates/Query/UniqueGUIDs\',RowsetId=\'1\')/Row',
});
this.getView().byId("idIconTabBar").insertContent(oTable); // add the table to the icontabbar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM