Kendo MultiSelect passing the placeholder as value in the search

0

I have a form with a Kendo UI MultiSelect component for ASP.NET MVC / Razor :

@(Html.Kendo().MultiSelectFor(m => m.Ids)
                .Filter(FilterType.Contains)
                .AutoBind(true)
                .MinLength(3)
                .Delay(500)
                .DataTextField("Value")
                .DataValueField("Key")
                .Placeholder("Please fill")
                .DataSource(
                    ds => ds.Read(
                        r => r.Action("FillMultiSelect", "ReportsController", new { companyId = IdentityManager.CompanyID, search = string.Empty })
                        ).ServerFiltering(true)
                )
            )

JavaScript for filter configuration:

var $ids = $("#Ids").data("kendoMultiSelect");

$ids.dataSource.transport.options.read.data = basicFilter($ids);

var basicFilter = function ($element) {
   return {
       companyId: self.form.getModel().CompanyId,
       search: $element.input.val()
   }
}

When I type the search text in the "Ids" field, the parameter passed to Action of the MVC is the value of the placeholder > field, not what was typed:

What's wrong with my code?

    
asked by anonymous 17.03.2017 / 12:10

1 answer

0

The error was in how to recover the value typed in MultiSelect . The correct thing is to use the array filters of object filter passed as parameter in event data . The corrected JavaScript code looks like this:

window.global.setDatasourceTransportFilter($("#Ids"), "kendoMultiSelect", basicFilter);

var basicFilter = function (e) {
   return {
       companyId: self.form.getModel().CompanyId,
       search: e.filter && e.filter.filters[0] ? e.filter.filters[0].value : ""
   }
}
    
20.03.2017 / 19:15