2017-04-14 32 views
0

是否可以在SAPUI5智能表中強制使用屬性,以便用戶在編輯時不能留空字段?SAPUI5智能表 - 智能字段使字段強制註釋

我發現this document說,這應該有可能在metadata.xml文件中設置必填字段控制的房產有這樣的註解:

<Property Name="NameLast" Type="Edm.String" Nullable="false" MaxLength="40" sap:label="Last name" sap:field-control="7" /> 

但與此設置我收到的控制檯以下錯誤:

2017-04-14 11:37:36.691429 MockServer: Resource not found for the segment '7' 
2017-04-14 11:37:36.707985 The following problem occurred: HTTP request failed404,Not Found,{"error":{"code":404,"message":{"lang":"en","value":"Resource not found for the segment '7'"}}} - 

編輯:

後來我發現,SAP:現場控制不應包含數字,而是一個明確的路徑離子到另一個包含數字的屬性。但是,這也不起作用:

<Property Name="NameLast" Type="Edm.String" Nullable="false" MaxLength="40" sap:label="Last name" sap:field-control="Name_fc" /> 
<Property Name="Name_fc" Type="Edm.Byte" /> 

Name_fc屬性的值爲'7'。我現在沒有看到任何控制檯錯誤,但是我仍然可以將輸入(NameLast)字段留空而不進行任何驗證,並將其發送到OData服務,這不是我所期望的。

以下是sap中使用必填字段的示例的鏈接。我不知道他們是如何做到的。 https://sapui5.netweaver.ondemand.com/sdk/explored.html#/sample/sap.ui.comp.sample.smartfield/code/SmartField.view.xml

+0

能否請你也張貼滿metadata.xml中? –

+0

metadata.xml中就在這裏 - https://jsfiddle.net/sL2zrt8j/ – sachad

回答

0

For OData v2 the sap:field-control annotation on the Property can be used to specify whether the field is mandatory.

<Property Name="Customer" ... sap:field-control="mandatory"/> 
<Property Name="CompanyCode" ... sap:field-control="mandatory"/> 

https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.comp.smartfield.SmartField.html

+0

很遺憾,您的解決方案導致了同樣的錯誤:未找到段「強制性」 資源 - 下面的問題出現了:HTTP請求failed404,未找到,{「錯誤」:{「code」:404,「消息」:{「lang」:「en」,「value」:「未找到該段的資源'必填項'}}}} – sachad