I have a web endpoint
public JsonResult GetCompanyPersonnelMany(string text, IEnumerable<int> includeIds)
{
I want to pass some data from a kendo multiselect. The multi select uses server side filtering; it uses a remote datasource; and it needs to process the data pre-flight.
My problem is that the text
parameter will be set, but includeIds
is always empty.
The pre-flight method looks like
var employeeComboDataPreFlight_loading = true;
function employeeComboDataPreFlight() {
var data = multiSelectPreFlightCommon(getMultiSelectByName('personnel'));
if (employeeComboDataPreFlight_loading) { data.includeIds = [568,572,585] || []; }
return data;
}
The multiselect is defined in the view as
@(Html.Kendo().MultiSelect()
.Name("personnel")
.Filter(FilterType.Contains)
.Placeholder("Select an option...")
.DataTextField(nameof(PersonnelEmployerViewModel.DisplayName))
.DataValueField(nameof(PersonnelEmployerViewModel.PersonnelId))
.MinLength(2)
.Value(Model.Select(x => x.PersonnelId))
.DataSource(source =>
{
source.Read(read =>
{
read.Action(nameof(PersonnelController.GetCompanyPersonnelMany),
ControllerName.Personnel
)
.Data("employeeComboDataPreFlight")
;
})
.ServerFiltering(true);
})
)
Evaluating the pre-flight method (in chrome console) shows the following:
> employeeComboDataPreFlight()
<- {text: "", includeIds: Array(3)}
includeIds: Array(3)
0: 568
1: 572
2: 585
> JSON.stringify(employeeComboDataPreFlight())
<- "{"text":"","includeIds":[568,572,585]}"
Opening the chrome network tab, it shows Query String Parameters:
text:
includeIds[]: 568
includeIds[]: 572
includeIds[]: 585
And my request URL:
Request URL: https://localhost:44363/Personnel/GetCompanyPersonnelMany?text=&includeIds%5B%5D=568&includeIds%5B%5D=572&includeIds%5B%5D=585
So it looks like there is an array of data for a variable named includeIds
being sent to the server.
My problem is that the controller isn't getting the the includeIds
parameter (the text
parameter works correctly), the List is always empty (non-null, length: 0). How do I get the kendo multiselect to pass my javascript array into a format the controller will accept?