【发布时间】:2019-12-11 18:54:50
【问题描述】:
我有一个网络端点
public JsonResult GetCompanyPersonnelMany(string text, IEnumerable<int> includeIds)
{
我想从剑道多选中传递一些数据。多选使用服务器端过滤;它使用远程数据源;并且需要在飞行前处理数据。
我的问题是text参数会被设置,但是includeIds总是空的。
飞行前方法看起来像
var employeeComboDataPreFlight_loading = true;
function employeeComboDataPreFlight() {
var data = multiSelectPreFlightCommon(getMultiSelectByName('personnel'));
if (employeeComboDataPreFlight_loading) { data.includeIds = [568,572,585] || []; }
return data;
}
多选在视图中定义为
@(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);
})
)
评估飞行前方法(在 chrome 控制台中)显示如下:
> employeeComboDataPreFlight()
<- {text: "", includeIds: Array(3)}
includeIds: Array(3)
0: 568
1: 572
2: 585
> JSON.stringify(employeeComboDataPreFlight())
<- "{"text":"","includeIds":[568,572,585]}"
打开chrome网络标签,显示查询字符串参数:
text:
includeIds[]: 568
includeIds[]: 572
includeIds[]: 585
还有我的请求网址:
Request URL: https://localhost:44363/Personnel/GetCompanyPersonnelMany?text=&includeIds%5B%5D=568&includeIds%5B%5D=572&includeIds%5B%5D=585
所以看起来有一个名为includeIds 的变量的数据数组正在发送到服务器。
我的问题是控制器没有获取includeIds 参数(text 参数正常工作),列表始终为空(非空,长度:0)。如何让 kendo 多选将我的 javascript 数组传递为控制器将接受的格式?
【问题讨论】:
标签: c# asp.net-core kendo-ui