我在 View 中使用多选 DevExtreme DropdownBox 并从模型中填充它 但我无法在 Post 方法的 Controller 中获取选定的值 我如何读取选定的值?
最佳答案
我得到了一个@Html.HiddenField
,然后在下面的js函数中填充了hiddenfield值:
function getSelectedItemsKeys(items) {
var result = [];
items.forEach(function (item) {
if (item.selected) {
result.push(item.key);
}
if (item.items.length) {
result = result.concat(getSelectedItemsKeys(item.items));
}
});
$("#myHF").val(result);
return result;
}
然后通过 View 模型将隐藏字段发送到 Controller 。
关于asp.net-core - 获取 DevExtreme DropDownBox 选定的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56512321/