3

I have a MVC Kendo UI AutoComplete control that I am binding to json data that contains HTML.

View:

@(Html.Kendo().AutoComplete()
.Name("MyAutoComplete")
.DataTextField("Text")
.Template("${  data.Text  }")
.DataSource(ds => ds.Read( read => read.Action("GetAutoCompleteItems", "Home"))
    .ServerFiltering(true)
 )
.MinLength(3))

Controller:

    public JsonResult GetAutoCompleteItems(string text)
    {
        var response = new List<SelectListItem>();

        response.Add(new SelectListItem{Text="<strong>My Html</strong> Text", Value="1"});

        return Json(response, JsonRequestBehavior.AllowGet);
    }

I can see that the control is encoding the template here:

'var o,e=kendo.htmlEncode;with(data){o=''+()+'=e(  data.Text  )';;o+='';}return o;' 

Is it possible to turn this off? I just want to highlight the text that matches my search string.

1 Answer 1

0

I do not know how exactly you would do it in MVC Kendo UI. But in general with a template like #= data.Text# it would work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.