溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

SAP UI5應用里搜索功能的實現(xiàn)是怎樣的

發(fā)布時間:2021-11-24 17:20:35 來源:億速云 閱讀:107 作者:柒染 欄目:互聯(lián)網(wǎng)科技

SAP UI5應用里搜索功能的實現(xiàn)是怎樣的,針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

在一個包含了list的XML視圖里,使用SearchField標簽頁定義一個搜索按鈕。點擊之后,執(zhí)行的事件處理函數(shù)為handleSearch:

<mvc:View controllerName="sapcp.cf.tutorial.app.controller.View1" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m">
	<Shell id="shell">
		<App id="app">
			<pages>
				<Page id="page" title="{i18n>title}">
					<subHeader>
						<Bar>
							<contentLeft>
								<SearchField search="handleSearch"/>
							</contentLeft>
						</Bar>
					</subHeader>
					<content>
						<List id="List" items="{/Products}">
							<ObjectListItem type="Navigation" press="handleListItemPress" title="{ProductName}" number="{= ((${UnitPrice} * 100) / 100).toFixed(2) }"
								numberUnit="{i18n>currency}">
								<attributes>
									<ObjectAttribute text="{QuantityPerUnit}"/>
								</attributes>
								<firstStatus>
									<ObjectStatus text="{= ${Discontinued}? 'Discontinued' : 'Available' }" state="{= ${Discontinued}? 'Error' : 'Success' }"/>
								</firstStatus>
							</ObjectListItem>
						</List>
					</content>
				</Page>
			</pages>
		</App>
	</Shell>
</mvc:View>

```

SAP UI5應用里搜索功能的實現(xiàn)是怎樣的

在視圖的控制器里實現(xiàn)這個搜索函數(shù):

```JavaScript

sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"sap/m/MessageBox"
], function (Controller, MessageBox) {
	"use strict";
	return Controller.extend("sapcp.cf.tutorial.app.controller.View1", {
		onInit: function () {
		},
		// show in a pop-up which list element was pressed
		handleListItemPress: function (oEvent) {
			var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
			var selectedProductId = oEvent.getSource().getBindingContext().getProperty("ProductID");
			oRouter.navTo("Detail", {
				productId: selectedProductId
			});
		}
	});
});

```

測試:

SAP UI5應用里搜索功能的實現(xiàn)是怎樣的

搜索能夠按照期望的工作:

SAP UI5應用里搜索功能的實現(xiàn)是怎樣的

關于SAP UI5應用里搜索功能的實現(xiàn)是怎樣的問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業(yè)資訊頻道了解更多相關知識。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI