В Index.cshtml
Код: Выделить всё
function SaveNewDoor() {
var newDoorData = [];
var table1 = $('#newTable').DataTable();
table1.rows().every(function (rowIdx, tableLoop, rowLoop)
{
var data = this.data();
var customModel = new Object();
customModel.siteCode = data[0]; // here all values are correct
customModel.legacyDoor = data[1];
customModel.brand = data[6];
customModel.buyingGroup = data[7];
customModel.settingname = data[9];
newDoorData.push(customModel);
});
$.ajax({
url: '@Url.Action("SaveSettings", "DOOR_MANAGEMENT")',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ newDoorData }),
success: function (result) { alert('Door Data changes saved'); },
error: function (xhr, status, error) {
console.log("Error:", error);
console.log("Status:", status);
console.log("XHR:", xhr);
}
});
}
Код: Выделить всё
[HttpPost]
public ActionResult SaveSettings(vmNewDoor[] model) // here model is empty
{
}
Код: Выделить всё
public class vmNewDoor
{
public int siteCode { get; set; }
public int legacyDoor { get; set; }
public string brand { get; set; }
public string buyingGroup { get; set; }
public string settingName { get; set; }
public int settingId { get; set; }
public string userId { get; set; }
public string status { get; set; }
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... controller
Мобильная версия