0
グリッド内のレコードを使ってインライン編集をしようとしています。MVC 3の編集Aazaxを使ったRazor Telerikグリッド
[保存]ボタンをクリックすると、関連付けられているコントローラーが正常に実行されます。
しかし、グリッドデータを保持するモデルからコントローラアクションにデータを取得する方法はわかりません。誰かが私を助けてくれますか?ここで
を見るためのコードである:ここで
@model Telerik.Web.Mvc.GridModel<YeagerTech.YeagerTechWcfService.Customer>
@{
ViewBag.Title = "Customer Index";
}
<h2>
Customer Index</h2>
@( Html.Telerik().Grid<YeagerTech.YeagerTechWcfService.Customer>(Model.Data)
.Name("Customers")
.DataKeys(dataKeys => dataKeys.Add(o => o.CustomerID)
.RouteKey("CustomerID"))
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Text).ImageHtmlAttributes(new { style = "margin-left:0" }))
.Columns(columns =>
{
columns.Bound(o => o.CustomerID).Hidden(true);
columns.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.Text);
}).Width(200).Title("Command");
columns.Bound(o => o.Email).Width(200);
columns.Bound(o => o.Company).Width(200);
columns.Bound(o => o.FirstName).Width(100).Title("FName");
columns.Bound(o => o.LastName).Width(100).Title("LName");
columns.Bound(o => o.Address1).Width(200).Title("Addr1");
columns.Bound(o => o.Address2).Width(100).Title("Addr2");
columns.Bound(o => o.City).Width(100);
columns.Bound(o => o.State).Width(40).Title("ST");
columns.Bound(o => o.Zip).Width(60);
//columns.Bound(o => o.HomePhone).Width(120);
//columns.Bound(o => o.CellPhone).Width(120);
//columns.Bound(o => o.Website).Width(100);
//columns.Bound(o => o.IMAddress).Width(100);
//columns.Bound(o => o.CreatedDate).Format("{0:MM/dd/yyyy}").ReadOnly(true).Width(120);
//columns.Bound(o => o.UpdatedDate).Format("{0:MM/dd/yyyy}").ReadOnly(true).Width(120);
}).DataBinding(dataBinding =>
dataBinding.Ajax()
.Insert("_InsertAjaxEditing", "Customer")
.Update("_SaveAjaxEditing", "Customer"))
.Editable(editing => editing.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
)
は、コントローラのコードです:
[HttpPost]
[GridAction]
public ActionResult _SaveAjaxEditing()
{
YeagerTechWcfService.Customer cust = new YeagerTechWcfService.Customer();
if (TryUpdateModel(cust))
{
try
{
db.EditCustomer(cust); // This is a WCF method which works fine...
TempData["ErrCode"] = "Customer successfully updated.";
return RedirectToAction("Index", "Home");
}
catch (Exception ex)
{
TempData["ErrCode"] = "CustErr";
ViewBag.Error = ex.Message;
return View();
}
}
else
return View();
}
、私は単純に次のようにモデルの内容を渡さ... 公共のActionResult _SaveAjaxEditing(YeagerTechWcfService.Customer CUST) – sagesky36
それがために働いている場合あなたは自分の質問に対する回答として追加することができますので、他人を助けるかもしれません。 –