[英]How to send selected datagrid objects with ajax in devextreme
Friends, with devextreme datagrid, I cannot capture the selected objects in the asp.net core controller.朋友们,使用 devextreme 数据网格,我无法捕获 asp.net 核心 controller 中的选定对象。 The values appear as json in chrome web tools.
这些值在 chrome web 工具中显示为 json。 But I can't fill the data with ajax on the controller side.
但我无法在 controller 端用 ajax 填充数据。 Thanks for help
感谢帮助
View:看法:
var datas=[];
var gDeger;
function selection_changed(selectedItems) {
datas = selectedItems.selectedRowsData;
$.map(datas,function (x) {
gDeger = [{ Id: x.Id, Email: x.Email }];
})
console.log(datas); //The values appear as json in chrome web tools
myfunction(datas);
};
function myfunction(gdeger) {
$.ajax({
type: "post",
dataType:"json",
url: "/Admin/SendSablon",
data: { eBultens: JSON.stringify(gdeger) },
success: function (message) {
console.log("true");
},
error: function () {
console.log("error");
}
});
}
Controller: Controller:
[HttpPost]
public IActionResult SendSablon(List<EBulten> eBultens) // eBultens is null =(
{
return Json(true);
}
On the controller side, you should use this to get your values:在 controller 方面,您应该使用它来获取您的值:
public IActionResult SendSablon(string values)
{
dynamic keys = JsonConvert.DeserializeObject(values);
var Id = keys.Id;
var Email = keys.Email;
// rest of code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.