I have a dropdownlist with multiple columns.
When a user wants to filter something, i want to retrieve all the records which contains the filter text in any column, not only on text column.
I have tried to manage the filter event, and change the filter, but its not working. What is it wrong with my code?
01.
@(Html.Kendo().DropDownList()
02.
.Name("CEBE")
03.
.HtmlAttributes(new { style = "width:100%" })
04.
.OptionLabel("Seleccione...")
05.
.HeaderTemplate("<
div
class=\"dropdown-header k-widget k-header\">" +
06.
"<
table
><
tr
>" +
07.
"<
td
style
=
'width:110px'
>CEBE</
td
>" +
08.
"<
td
>Nombre</
td
>" +
09.
"</
tr
></
tabla
>" +
10.
"</
div
>")
11.
.Template("<
span
class=\"k-state-default\"></
span
>" +
12.
"<
span
class=\"k-state-default\">" +
13.
"<
table
><
tr
>" +
14.
"<
td
style
=
'width:110px; padding-right:5px;'
>#: data.Codigo#</
td
>" +
15.
"<
td
style
=
'width:auto;'
>#: data.Nombre#</
td
>" +
16.
"</
tr
></
table
>" +
17.
"</
span
>")
18.
.DataTextField("Nombre")
19.
.DataValueField("Codigo")
20.
.Filter(FilterType.Contains)
21.
.Events(e=> e.Filtering("filterCebe"))
22.
.BindTo((List<
Sample.MaestrosService.CEBE
>)ViewBag.ListaCebesUtilizados)
23.
)
24.
25.
26.
<script text="text/javascript">27.
function filterCebe(e) {
28.
debugger;
29.
var filterValue = e.filter.value;
30.
var newFilter = {
31.
logic: "or",
32.
filters: [
33.
{ field: "Nombre", operator: "contains", value: filterValue, ignoreCase: true },
34.
{ field: "Codigo", operator: "contains", value: filterValue, ignoreCase: true }
35.
]
36.
};
37.
var dll = $("#CEBE").data("kendoDropDownList");
38.
dll.dataSource.filter(newFilter);
39.
} </script>