Stackoverflow コミュニティの皆様、こんにちは。
私の問題を説明するために、小さなサンプル アプリケーションを作成しました。mvc 5 と Infragistics Ignite UI igGrid を使用しています。ページはこんな感じです。
ビューに渡すモデルは 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;
}
}
私のビューは次のようになります
「保存」ボタンをクリックした後、会社と従業員テーブルからデータを保存する必要があります。複雑な検証を行っているため、これはボタンを 1 回クリックするだけで実行する必要があります。従業員テーブルの保存に問題はありませんが、会社の属性 (会社名と会社の住所) の保存に問題があります。
どうもありがとうございました。