【问题标题】:SAP Split App SAPUI5 Data Refresh doesnt work in Detail viewSAP Split App SAPUI5 数据刷新在详细视图中不起作用
【发布时间】:2018-01-30 07:33:35
【问题描述】:

事实上,我的问题已经在这里SAPUI5 OData Binding not refreshing on route navigation 之前被问过,但是由于该特定帖子中没有提供答案,我需要在这里以某种方式重新发布它,因为我既不能评论提到的帖子,也不能我给海报发消息。

我的应用程序中的几乎所有内容都可以正常工作,但 Detailview 中 ObjectHeaders 的所有数据字段只会写入一次。第一次写入一个值后,它就再也不会改变了。

有人知道它为什么会这样吗?

编辑:你们是对的人,我很抱歉。

这就是我设置App模型的init函数:

            init : function () {
            this.oListSelector = new ListSelector();
            this._oErrorHandler = new ErrorHandler(this);
            // set the device model
            this.setModel(models.createDeviceModel(), "device");
            // set the FLP model
            this.setModel(models.createFLPModel(), "FLP");
            // set the dataSource model
            this.setModel(new sap.ui.model.json.JSONModel({"uri":"*placeholder*/sap/opu/odata/SAP/Z_APPROVALSERVICE_SRV/"}), "dataSource");
            // call the base component's init function and create the App view
            UIComponent.prototype.init.apply(this, arguments);

            // create the views based on the url/hash
            this.getRouter().initialize();
        }

接着是我的拆分应用程序的主视图:

<mvc:View xmlns:mvc="sap.ui.core.mvc" controllerName="com.sap.build.standard.approvalApp.controller.Worklist" xmlns:m="sap.m">
<m:Page showHeader="true" title="{masterView>/title}" showFooter="true">
    <m:content>
        <m:List id="sap_m_List_1" mode="SingleSelectMaster" width="100%" headerText="Header" footerText="" backgroundDesign="Solid" showSeparators="All" growing="false" growingThreshold="20" growingScrollToLoad="true" itemPress="_onListItemPress1" items="{/GeneralDataSet}">
            <m:items>
                <m:ObjectListItem intro="{Description}" title="{path: 'DueDate', type: 'sap.ui.model.type.Date', formatOptions: { UTC: true, style: 'short' }}" number="{Priority}" numberUnit="" numberState="None" type="Active" selected="false" showMarkers="false">
                    <m:attributes/>
                    <m:firstStatus>
                        <m:ObjectStatus title="Estimated Validation Effort" text="{EstimatedValidationEffort}" state="None"/>
                    </m:firstStatus>
                    <m:secondStatus>
                        <m:ObjectStatus title="Estimated Implementation Effort" text="{EstimatedImplEffort}" state="None"/>
                    </m:secondStatus>
                </m:ObjectListItem>
            </m:items>
            <m:headerToolbar>
                <m:Toolbar visible="true" enabled="true" width="" design="Solid">
                    <m:content>
                        <m:SearchField value="" placeholder="Insert term to search for" showSearchButton="false" visible="true" liveChange="_onSearchFieldLiveChange"/>
                    </m:content>
                </m:Toolbar>
            </m:headerToolbar>
        </m:List>
    </m:content>
    <m:footer>
        <m:Bar design="Footer">
            <m:contentLeft/>
            <m:contentMiddle/>
            <m:contentRight/>
        </m:Bar>
    </m:footer>
    <m:headerContent/>
    <m:subHeader/>
</m:Page>

...详细视图

<mvc:View xmlns:mvc="sap.ui.core.mvc" controllerName="com.sap.build.standard.approvalApp.controller.BusinessTransaction" xmlns:m="sap.m" xmlns:layout="sap.ui.layout" xmlns:form="sap.ui.layout.form">
<m:Page showHeader="true" title="Master View" showFooter="true" showNavButton="false">
    <m:content>
        <layout:VerticalLayout width="100%" visible="true">
            <layout:content>
                <m:ObjectHeader intro="Due Date" title="{path: 'DueDate', type: 'sap.ui.model.type.Date', formatOptions: { UTC: true, style: 'short' }}" number="{Priority}" numberUnit="" numberState="None" showMarkers="false" markFavorite="false" markFlagged="false" backgroundDesign="Transparent" condensed="false">
                    <m:attributes>
                        <m:ObjectAttribute title="" text="{Description}" active="false"/>
                    </m:attributes>
                    <m:statuses/>
                </m:ObjectHeader>
                <m:IconTabBar expandable="true" expanded="true" applyContentPadding="false" backgroundDesign="Solid" upperCase="false" visible="true" selectedKey="Ok">
                    <m:content/>
                    <m:items>
                        <m:IconTabFilter icon="sap-icon://hint" iconColor="Default" text="Header Data" count="" design="Vertical" enabled="true" showAll="false" textDirection="Inherit" visible="true">
                            <m:content>
                                <m:ObjectHeader intro="" title="{ID}" icon="" number="" numberUnit="" numberState="None" showMarkers="false" markFavorite="false" markFlagged="false" backgroundDesign="Translucent" condensed="false">
                                    <m:attributes>
                                        <m:ObjectAttribute title="Current Status" text="{Status}" active="false"/>
                                        <m:ObjectAttribute title="Category" text="{Category}" active="false"/>
                                        <m:ObjectAttribute title="Classification" text="{Classification}" active="false"/>
                                        <m:ObjectAttribute title="Assignee" text="{Assignee}" active="false"/>
                                        <m:ObjectAttribute title="Created by" text="{CreatedBy}" active="false"/>
                                        <m:ObjectAttribute title="Created at" text="{path: 'CreatedAt', type: 'sap.ui.model.type.Date', formatOptions: { UTC: true, style: 'short' }}" active="false"/>
                                        <m:ObjectAttribute title="Last changed by" text="{LastChangedBy}" active="false"/>
                                        <m:ObjectAttribute title="Last changed at" text="{path: 'LastChangedAt', type: 'sap.ui.model.type.Date', formatOptions: { UTC: true, style: 'short' }}" active="false"/>
                                    </m:attributes>
                                    <m:statuses/>
                                </m:ObjectHeader>
                            </m:content>
                        </m:IconTabFilter>
                        <m:IconTabFilter icon="sap-icon://comment" iconColor="Default" text="Comments" count="" design="Vertical" showAll="false" textDirection="Inherit" enabled="true" visible="true" iconDensityAware="false">
                            <m:content>
                                <m:List width="100%" growing="false" growingThreshold="20" growingScrollToLoad="false" backgroundDesign="Solid" items="{commented}">
                                    <m:items>
                                        <m:FeedListItem icon="" sender="{ID}" text="{CreatedBy}" info="{path: 'CreatedAt', type: 'sap.ui.model.type.Date', formatOptions: { UTC: true, style: 'short' }}" timestamp="{Comment}"/>
                                    </m:items>
                                </m:List>
                                <m:FeedInput showIcon="false" icon="" placeholder="Type your comment here" enabled="true" visible="true" maxLength="0" buttonTooltip="Submit"/>
                            </m:content>
                        </m:IconTabFilter>
                        <m:IconTabFilter icon="sap-icon://approvals" iconColor="Default" text="Approvals" count="" design="Vertical" showAll="false" textDirection="Inherit" enabled="true" visible="true" iconDensityAware="false">
                            <m:content>
                                <m:List id="approvalList" mode="SingleSelectMaster" width="100%" headerText="Header" footerText="" backgroundDesign="Solid" showSeparators="All" growing="true" growingThreshold="20" growingScrollToLoad="true" items="{wantToBeApproved}" press="_onButtonPress8">
                                    <m:infoToolbar>
                                        <m:Toolbar width="100%" height="auto" design="Auto" visible="false" enabled="true">
                                            <m:content>
                                                <m:Label text="Label" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit"/>
                                            </m:content>
                                        </m:Toolbar>
                                    </m:infoToolbar>
                                    <m:headerToolbar>
                                        <m:Toolbar visible="true" enabled="true" width="" design="Solid">
                                            <m:content>
                                                <m:SearchField placeholder="Search" showSearchButton="true" visible="true" width="100%"/>
                                            </m:content>
                                        </m:Toolbar>
                                    </m:headerToolbar>
                                    <m:items>
                                        <m:ObjectListItem intro="{ID}" title="{ApproverRole}" number="{Decision}" numberUnit="" numberState="None" type="Active" selected="true" showMarkers="false">
                                            <m:attributes>
                                                <m:ObjectAttribute text="{ApproverName}" active="false"/>
                                                <m:ObjectAttribute text="{ApproverUser}" active="false"/>
                                            </m:attributes>
                                            <m:firstStatus>
                                                <m:ObjectStatus text="{ApproverRole}" state="None"/>
                                            </m:firstStatus>
                                            <m:secondStatus>
                                                <m:ObjectStatus title="Pass" text="{Pass}" state="None"/>
                                            </m:secondStatus>
                                        </m:ObjectListItem>
                                    </m:items>
                                </m:List>
                            </m:content>
                        </m:IconTabFilter>
                        <m:IconTabFilter icon="sap-icon://project-definition-triangle" iconColor="Default" text="Change Definitions" count="" design="Vertical" showAll="false" textDirection="Inherit" enabled="true" visible="true" iconDensityAware="false">
                            <m:content>
                                <m:List mode="SingleSelectMaster" width="100%" headerText="Header" footerText="" backgroundDesign="Solid" showSeparators="All" growing="true" growingThreshold="20" growingScrollToLoad="true">
                                    <m:infoToolbar>
                                        <m:Toolbar width="100%" height="auto" design="Auto" visible="false" enabled="true">
                                            <m:content>
                                                <m:Label text="Label" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit"/>
                                            </m:content>
                                        </m:Toolbar>
                                    </m:infoToolbar>
                                    <m:headerToolbar>
                                        <m:Toolbar visible="true" enabled="true" width="" design="Solid">
                                            <m:content>
                                                <m:SearchField placeholder="Search" showSearchButton="true" visible="true" width="100%"/>
                                            </m:content>
                                        </m:Toolbar>
                                    </m:headerToolbar>
                                    <m:items/>
                                </m:List>
                            </m:content>
                        </m:IconTabFilter>
                        <m:IconTabFilter icon="sap-icon://attachment" iconColor="Default" text="Attachments" count="" design="Vertical" showAll="false" textDirection="Inherit" enabled="true" visible="true" iconDensityAware="false">
                            <m:content>
                                <m:UploadCollection uploadEnabled="false" numberOfAttachmentsText="" showSeparators="All" noDataText="The UploadCollection coming from BUILD cannot work in WebIDE without additional work" maximumFileSize="10" mimeType="image/jpeg,image/gif,image/png,text/plain,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" multiple="false" uploadUrl="" sameFilenameAllowed="false" mode="SingleSelectMaster" uploadComplete="_onUploadCollectionUploadComplete" change="_onUploadCollectionChange" typeMissmatch="_onUploadCollectionTypeMissmatch" fileSizeExceed="_onUploadCollectionFileSizeExceed">
                                    <m:headerParameters/>
                                    <m:items/>
                                    <m:parameters/>
                                    <m:toolbar/>
                                </m:UploadCollection>
                            </m:content>
                        </m:IconTabFilter>
                        <m:IconTabFilter icon="sap-icon://history" iconColor="Default" text="Protocol" count="" design="Vertical" showAll="false" textDirection="Inherit" enabled="true" visible="true" iconDensityAware="false">
                            <m:content>
                                <m:List mode="SingleSelectMaster" width="100%" headerText="Header" footerText="" backgroundDesign="Solid" showSeparators="All" growing="true" growingThreshold="20" growingScrollToLoad="true">
                                    <m:infoToolbar>
                                        <m:Toolbar width="100%" height="auto" design="Auto" visible="false" enabled="true">
                                            <m:content>
                                                <m:Label text="Label" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit"/>
                                            </m:content>
                                        </m:Toolbar>
                                    </m:infoToolbar>
                                    <m:headerToolbar>
                                        <m:Toolbar visible="true" enabled="true" width="" design="Solid">
                                            <m:content>
                                                <m:SearchField placeholder="Search" showSearchButton="true" visible="true" width="100%"/>
                                            </m:content>
                                        </m:Toolbar>
                                    </m:headerToolbar>
                                    <m:items/>
                                </m:List>
                            </m:content>
                        </m:IconTabFilter>
                    </m:items>
                </m:IconTabBar>
            </layout:content>
        </layout:VerticalLayout>
        <form:ResponsiveGridLayout columnsM="1" columnsL="2" emptySpanL="0" emptySpanM="0" emptySpanS="0" visible="true" labelSpanS="12" labelSpanM="2" labelSpanL="4"/>
    </m:content>
    <m:footer>
        <m:Bar design="Auto">
            <m:contentLeft/>
            <m:contentMiddle/>
            <m:contentRight>
                <m:Button text="Forward" type="Default" iconFirst="true" width="auto" enabled="false" visible="false" iconDensityAware="false" press="_onButtonPress7"/>
                <m:Button text="Approve" type="Accept" iconFirst="true" width="auto" enabled="true" visible="true" iconDensityAware="false" press="_onButtonPress8"/>
                <m:Button text="Reject" type="Reject" iconFirst="true" width="auto" enabled="true" visible="true" iconDensityAware="false" press="_onButtonPress9"/>
            </m:contentRight>
        </m:Bar>
    </m:footer>
    <m:headerContent/>
    <m:subHeader/>
</m:Page>

由于我不是一个优秀的程序员,我不确定您还需要什么,所以如果有任何遗漏,请告诉我。

问题是,Detail 视图中的 ObjectHeaders 只用数据刷新一次。此外,如果字段为空,则字段似乎只写入一次。在第一次将数据设置到 ObjectAttribute 字段后,以后再也不会更改。

这是为什么? (这与引用的帖子中提到的完全相同的问题)

【问题讨论】:

  • 你能提供任何代码吗?还是配置?
  • 没有代码很难理解这个问题...
  • 我编辑了根帖子
  • 为什么您的 dataSource 模型是 JSONModel 而不是 oDataModel,因为这似乎是您正在使用的源? oData 模型类在跟踪刷新等方面做得更多

标签: data-binding odata sapui5


【解决方案1】:

因为这是一个 JSON 模型,你可以试试这个:

var oModel = new sap.ui.model.json.JSONModel();
setInterval(function() {
  var uri = "*placeholder*/sap/opu/odata/SAP/Z_APPROVALSERVICE_SRV/"
  oModel.loadData(uri, true);
}, 1000);
this.setData(oModel, "dataSource");

虽然我不建议使用setInterval,但您可以将uri 包裹在deltatimer DeltaTimer 中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多