1

我将 Kendo UI Autocomplete 与 ASMX 服务一起使用,该服务返回如下字符串数组:

<ArrayOfString>
    <string>One string</string>
    ...
</ArrayOfString>

除了项目列表打开两次外,一切正常。一键关闭一个列表,“第二个后面”仍然打开。当列表打开时,我们可以看到第二个列表在第一个列表后面打开。

任何想法 ?

JS代码:

<input id="autoCompleteTest" />
<script>
    var dataSource = new kendo.data.DataSource({
        serverFiltering: true,
        transport: {
            read: {
                data: {
                    startswith: function(){
                        return $("#autoCompleteTest").data("kendoAutoComplete").value();
                    }
                },
                url: "WebService.asmx/GetStrings",
                type: "POST",
            }
        },
        schema: {
            // specify the the schema is XML
            type: "xml",
            // the XML element which represents a single data record
            data: "/ArrayOfString/string",
            // define the model - the object which will represent a single data record
            model: {
                // configure the fields of the object
                fields: {
                // the "title" field is mapped to the text of the "title" XML element
                value: "text()"
            }
        }
    }
});
$("#autoCompleteTest").kendoAutoComplete({
    minLength: 3,
    dataValueField : "value",
    dataTextField : "value",
dataSource: dataSource
});
</script>

C#代码:

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public String[] GetStrings(string startswith)
{
    using (var dataContext = new DataClassesDataContext())
    {
        var query = from x in dataContext.product where x.shortName.StartsWith(startswith) select x.shortName;
        return query.ToArray();
    }
}
4

2 回答 2

0

我遇到了类似的问题并在此处发布

请确认您的自动完成控件不位于另一个强制 Kendo 控件再次渲染的控件内。

于 2014-04-17T12:52:28.930 回答
0

当 dom 准备好进行 kendo 多选时,您是否编写客户端代码:$(document).ready(function () { ..yourcode.});

见:http ://docs.telerik.com/kendo-ui/controls/editors/multiselect/overview#accessing-an-existing-multiselect

于 2017-09-26T11:12:46.853 回答