Hi. I'm attempting to bold matched text from the autocomplete textbox in the suggestions list and am having some difficulty. I'm passing a simple list of strings to the autocomplete control not an object. I know I need to use a template to accomplish what I'm trying to do. I realize my template line is completely wrong but I put there the kind of pseudo-code to convey the idea of what I want. If someone could nudge me in the right direction as to a possible solution I would be very much appreciative.
Thanks!
Thanks!
<div class=
"DCF"
>
@using (Html.BeginForm(
"Search"
,
"Search"
, FormMethod.Post,
new
{ enctype =
"multipart/form-data"
}))
{
<span>DCF DB</span>
@(Html.Kendo().AutoComplete()
.Name(
"dcfSearchBox"
)
//
.DataTextField(
"results"
) //commented as the list of strings do not need a dataTextField defined to display
.Filter(
"contains"
)
.MinLength(3)
.HtmlAttributes(
new
{ style =
"width:250px"
})
.DataSource(source =>
{
source.Read(read =>
{
read.Action(
"SuggestionSearch"
,
"Search"
).Data(
"onAdditionalData"
);
})
.ServerFiltering(
true
);
})
.Template(
"#:results.Replace(dcfSearchBox.val(),\"<span style='font-weight: bold;'>#:dcfSearchBox.val()</span>\")#"
)
)
<br />
@(Html.Kendo().Button()
.Name(
"btnSubmit"
)
.HtmlAttributes(
new
{ type =
"submit"
})
.Content(
"Search"
)
)
}
</div>
<script>
function
onAdditionalData() {
return
{
text: $(
"#dcfSearchBox"
).val()
//,
//checkFilter: $("#dcfCheckFilter").is(':checked'),
//filterText: $("#dcfFilterText").val()
};
}
</script>