Sap.m.Input的自定义表格建议

时间:2017-02-16 07:40:34

标签: sapui5

我想为SAPUI5中的输入字段创建自定义建议。我设法创建了一个表格建议,其中包括3列{NameAdNameTelno}。 这是我的代码:

<Input id="_txtCustomerName" liveChange="liveChange" placeholder="{i18n>customername}" showTableSuggestionValueHelp="false" 
        suggestionItemSelected="suggestionSelected" startSuggestion="1" showSuggestion="true" suggest="suggest" suggestionRows="{/results}" >
            <suggestionColumns>
                <Column hAlign="Begin" popinDisplay="Inline" demandPopin="true">
                    <Label text="{i18n>customername}"/>
                </Column>
                <Column hAlign="Center" popinDisplay="Inline" demandPopin="true" minScreenWidth="Tablet">
                    <Label text="{i18n>address}"/>
                </Column>
                <Column hAlign="End" popinDisplay="Inline" demandPopin="true">
                    <Label text=" {i18n>phoneno}"/>
                </Column>
            </suggestionColumns>
            <suggestionRows>
                <ColumnListItem>
                <cells>
                    <Label text="{Name}"/>
                    <Label text="{AdName}, {City}"/>
                    <Label text="{Telno}"/>
                </cells>
                </ColumnListItem>
            </suggestionRows>
        </Input>

它正确地将数据从ABAP服务器加载到SuggestionRows属性,仅由Name过滤。现在我想要按NameTelno过滤建议表。有什么建议吗? P / s:我试图遵循这个帖子的指南:https://archive.sap.com/discussions/thread/3811696但它似乎对我不起作用。

    suggest: function(oEvent) {
                var sValue = oEvent.getParameter("suggestValue");
                var filters = new sap.ui.model.Filter([
                    new sap.ui.model.Filter("Name",
                        sap.ui.model.FilterOperator.Contains,
                        sValue),
                    new sap.ui.model.Filter("Telno",
                        sap.ui.model.FilterOperator.Contains,
                        sValue)
                ], false);
                oEvent.getSource().getBinding("suggestionRows").filter(
                    [filters]);
}

它会为oEvent.getSource().getBinding("suggestionRows")返回undefind,表示我无法找到suggestionRows聚合。

1 个答案:

答案 0 :(得分:1)

sap.m.Input 控件将按“名称”过滤数据,即使您添加了自己的过滤器也是如此。您必须停用默认过滤器&amp;添加自己的过滤器逻辑。您可以通过将filterSuggests属性更改为false来禁用它。

<Input id="_txtCustomerName" filterSuggests="false" ....

这将禁用控件使用的默认过滤逻辑here。现在您的自定义过滤器逻辑应该可以工作。

相关问题