你好 Stackoverflow 社区,
我制作了一个小示例应用程序来说明我的问题。我正在使用 mvc 5 和 Infragistics Ignite UI igGrid。这就是页面的样子。
我传递给 View 的模型是 Company 类。
public class Company
{
public int ID { get; set; }
public string CompanyName { get; set; }
public string Address { get; set; }
public IQueryable<Employee> EmployeeList { get; set; }
}
And the Employee Class:
public class Employee
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
这就是我的控制器的样子
// GET: Company
public ActionResult Index()
{
Company myCompany = new Company { ID = 1, CompanyName = "Cool Company", Address = "USA" };
Employee employee1 = new Employee { ID = 10, FirstName = "Christiano", LastName = "Ronaldo" };
Employee employee2 = new Employee { ID = 11, FirstName = "Sebastian", LastName = "Schweinsteiger" };
List<Employee> employeeList = new List<Employee>();
employeeList.Add(employee1);
employeeList.Add(employee2);
myCompany.EmployeeList = employeeList.AsQueryable();
return View("Index", myCompany);
}
[HttpPost]
public ActionResult SaveData()
{
GridModel gridModel = new GridModel();
List<Transaction<Employee>> transactions = gridModel.LoadTransactions<Employee>(HttpContext.Request.Form["ig_transactions"]);
// here im getting the changes of the employee table. This works fine. But how do I get the changes of my company?
foreach (Transaction<Employee> t in transactions)
{
//do something..
}
JsonResult result = new JsonResult();
Dictionary<string, bool> response = new Dictionary<string, bool>();
response.Add("Success", true);
result.Data = response;
return result;
}
}
我的视图看起来像这样
单击“保存”按钮后,我需要保存公司和员工表中的数据。这必须一键执行,因为我正在做一些复杂的验证。我没有保存员工表的问题,但我在保存公司属性(公司名称和公司地址)时遇到了问题。
非常感谢。