0

在 sap fiori 应用程序中,搜索栏适用于模拟数据,而不适用于后端数据(sap ABAP(odata))

文件名:Master.Controller.js

 onSearch : function() {
            this.oInitialLoadFinishedDeferred = jQuery.Deferred();
            // Add search filter
            var filters = [];
            var searchString = this.getView().byId("searchField").getValue();
            if (searchString && searchString.length > 0) {
                filters = [ new sap.ui.model.Filter("QUARTER_ID", sap.ui.model.FilterOperator.Contains, searchString) ];
            }
            // Update list binding
            this.getView().byId("list").getBinding("items").filter(filters);

            //On phone devices, there is nothing to select from the list
            if (sap.ui.Device.system.phone) {
                return;
            }

            //Wait for the list to be reloaded
            this.waitForInitialListLoading(function () {
                //On the empty hash select the first item
                this.selectFirstItem();
            });
        },

文件名:Master.view.xml

  <subHeader id="masterSubHeader">
                <Bar id="searchBar">
                    <contentMiddle>
                        <SearchField 
                            id="searchField" 
                           livechange= "onSearch" 
                            width="100%">
                        </SearchField>
                    </contentMiddle>
                </Bar>
            </subHeader>
            <content>
                <List 
                    id="list" 
                    select="onSelect" 
                    mode="{device>/listMode}" 
                    noDataText="{i18n>masterListNoDataText}" 
                    growing="true" 
                    growingScrollToLoad="true" 
                    items="{/quarterviewSet}">
                    <items
                        id="masterList">
                        <ObjectListItem 
                            id="mainListItem" 
                            press="onSelect" 
                            type="{device>/listItemType}" 
                            counter="0" 
                            title="{QUARTER_ID}" 
                            number="{QTRTYPE_NAME}" 
                            numberUnit="{QUARTER_CATEGORY}"
                            markFavorite="false" 
                            markFlagged="false" 
                            showMarkers="false">
                             <attributes> 
                            <ObjectAttribute id="ATTR1" text="{LOCATION}" />
                            <ObjectAttribute id="ATTR2" text="{CITY}" />
                        </attributes> 
                            <core:ExtensionPoint 
                                name="extListItemInfo"/>
                        </ObjectListItem>
                    </items>
                </List>
            </content>
4

1 回答 1

0

您必须弄清楚来自后端的数据是否与模拟数据相同。如果没有,绑定可能出错了。请检查数据是否最初与所有后端数据一起加载到列表中。之后,尝试进行搜索。在函数中放置一个断点onSearch,查看数据是否仍然存在以及如何创建过滤器。

于 2015-04-11T04:16:59.163 回答