Sapui5 如何避免键入前导零?
我有一个支持这个建议的意见 要搜索数字,我必须先键入前导零。我怎样才能绕过它 守则:Sapui5 如何避免键入前导零?,sapui5,Sapui5,我有一个支持这个建议的意见 要搜索数字,我必须先键入前导零。我怎样才能绕过它 守则: <Label text="Assign to" labelFor="pmRespPers"/> <Input id="pmRespPers" type="Text" placeholder="Enter Person respons." showSuggestion="true" suggestionRows="{EAMMALFUNCTION>/I_PMContactCardE
<Label text="Assign to" labelFor="pmRespPers"/>
<Input id="pmRespPers" type="Text" placeholder="Enter Person respons." showSuggestion="true"
suggestionRows="{EAMMALFUNCTION>/I_PMContactCardEmployee}">
<layoutData>
<layout:GridData span="L7 M7 S12"/>
</layoutData>
<suggestionColumns>
<Column hAlign="Begin" popinDisplay="Inline" demandPopin="true">
<Label text="Number"/>
</Column>
<Column hAlign="Center" popinDisplay="Inline" demandPopin="true" minScreenWidth="Tablet">
<Label text="Fullname"/>
</Column>
</suggestionColumns>
<suggestionRows>
<ColumnListItem>
<cells>
<Label text="{EAMMALFUNCTION>PersonnelNumber}"/>
<Label text="{EAMMALFUNCTION>EmployeeFullName}"/>
</cells>
</ColumnListItem>
</suggestionRows>
</Input>
在输入中使用。每次用户输入时,它都会被激发
作为事件对象的参数,您可以获得“值”。
因此,在事件处理函数中,根据需要修改值(添加零),并使用修改后的值过滤建议列表
您还需要禁用默认筛选以避免冲突。下面是代码片段:
带表格建议的代码段:
我找到了解决方案:
onSuggest: function(oEvent) {
const oSuggestionRows = oEvent.getSource().getSuggestionRows();
oSuggestionRows.map(a => {
const oFirstLabel = a.getCells()[0];
const iPersonnel = oFirstLabel.getText();
const iPlConverted = parseInt(iPersonnel, 10);
oFirstLabel.setText(iPlConverted);
return oFirstLabel;
});
使用
oEvent.getParameters().suggestionColumns
,我得到了未定义的。为什么?对不起,我想我误解了API。我认为“suggestionColumns”仅在配置表格建议时定义。在答案中检查我的更新。因此无法将其与suggestionRows
一起使用?当然,您当然可以。。。只需更改从输入对象获得的绑定,如下所示oEvent.getSource().getBinding(“suggestionRows”).filter(oFilter)代码>我写了另一段代码来显示它。我回答的最后一行
onSuggest: function(oEvent){
var sValue = oEvent.getParameters().suggestValue;
var sModifiedValue = "0000" + sValue;
var oFilter = new sap.ui.model.Filter("Name", sap.ui.model.FilterOperator.StartsWith, sModifiedValue);
oEvent.getSource().getBinding("suggestionItems").filter(oFilter);
}
onSuggest: function(oEvent) {
const oSuggestionRows = oEvent.getSource().getSuggestionRows();
oSuggestionRows.map(a => {
const oFirstLabel = a.getCells()[0];
const iPersonnel = oFirstLabel.getText();
const iPlConverted = parseInt(iPersonnel, 10);
oFirstLabel.setText(iPlConverted);
return oFirstLabel;
});