0

是否可以从 KeondoUI 自动完成配置选定的选项?我期待显示带有十字图标的文本,因此当用户单击十字时,该值将从自动完成框中删除。下面来自架构的代码在文本框中显示为 html,我无法解析它。

在此处输入图像描述

参考代码:

        $("#txtSearch").kendoAutoComplete({
            template: '<span class="hide">#: data.Value #</span><span>#:     data.Text #    </span>',
            dataTextField: "Name",
            filter: "contains",
            minLength: 3,
            placeholder: "Find User",
            separator: ", ",
            noDataTemplate: 'No user found',
            dataSource: dataSourceForUser,
            select: onSelectUser
        });

        function onSelectUser(e) {        
            selectedAttendees.push({
                Value: e.item["0"].childNodes["0"].outerText,
                Text: e.item["0"].childNodes["1"].outerText,
                AdditionData: e.item["0"].childNodes["2"].outerText
            });

            console.log(selectedAttendees);
        }

        var dataSourceForUser = new kendo.data.DataSource({
            type: "json",
            serverFiltering: true,
            transport: {
                read: {
                    url: "someUserFilter",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json"
                },
                parameterMap: function (options, operation) {
                    if (operation === "read") {
                        return { content: options.filter.filters["0"].value };
                    }
                }
            },
            schema: {
                parse: function (response) {
                    var length = response.length;
                    var dataItem;
                    var idx = 0;

                    for (; idx < length; idx++) {
                        dataItem = response[idx];
                        dataItem.Name = '<span style=\'border:1px solid red;\'>' + dataItem.Text + '</span>';
                    }

                    return response;
                }
            }
        });

任何帮助,将不胜感激。

4

0 回答 0