Вот мой код:
Класс модели (размещен на уровне службы) -
Код: Выделить всё
public class RDSSuperProfileVM
{
public string principalCo { get; set; }
public string nameOfProp1 { get; set; }
public string nameOfProp2 { get; set; }
public string residenceAddress1 { get; set; }
public string residenceAddress2 { get; set; }
public string contactNo1 { get; set; }
public string contactNo2 { get; set; }
public string emailAddress { get; set; }
public List distributorsList { get; set; }
}
public class RDS_Distributors
{
public string distributorForCompany { get; set; }
public string dateOfAppointment { get; set; }
public string currentAvgMonthlyBusiness { get; set; }
public string paymentTerm { get; set; }
public string nofRoutes { get; set; }
public string nofOutlets { get; set; }
}
Код: Выделить всё
Principal Co.
Email Address:
Name of Propreiter/Partner/Director 1:
Name of Propreiter/Partner/Director 2:
Residence Address 1
Residence Address 2
Contact Number 1:
Contact Number 2:
CURRENT BUSINESS DETAILS
Distributor for Companies
Date of Appoint.
Current Avg. Monthly Business
Payment Term
No. of Routes / Subs
No. of Outlets
+
X
Submit
Cancel
Код: Выделить всё
$("#btnSave").click(function () {
var distributorData = [];
$('#tblDistributors > tbody > tr').each(function (ind, val) {
if (ind > 0) {
var distributors =
{
"distributorForCompany": $(val).find("input[name='distributorForCompany']").val(),
"dateOfAppointment": $(val).find("input[name='dateOfAppointment']").val(),
"currentAvgMonthlyBusiness": $(val).find("input[name='currentAvgMonthlyBusiness']").val(),
"paymentTerm": $(val).find("input[name='paymentTerm']").val(),
"nofRoutes": $(val).find("input[name='nofRoutes']").val(),
"nofOutlets": $(val).find("input[name='nofOutlets']").val()
};
distributorData.push(distributors);
}
});
console.log(distributorData );
$.ajax({
type: "POST",
url: "/RDSuperProfile/GetData",
data: JSON.stringify(distributorData),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
},
error: function (response) {
alert(response.responseText);
}
});
})
Код: Выделить всё
public JsonResult GetData(List distributorData)
{
return Json("Success");
}
введите здесь описание изображения
введите здесь описание изображения
введите здесь описание изображения
Было бы здорово, если бы данные таблицы можно было отправлять вместе с данными другого входного поля формы, в противном случае я буду использовать отдельный параметр для получения данных таблицы и данных сериализации формы. Пожалуйста, помогите, так как я не понимаю, почему данные таблицы не доходят до контроллера.
Подробнее здесь: https://stackoverflow.com/questions/793 ... o-controll