Dear Wizards of the Realm,
New to MVC4 and to Kendo. So probably some misconceptions. Tried for a couple days. Need suggestions.
1. Started Visual Studio 2012 new project using Asp.net mvc 4 web app. Connected to existing database with edmx file. Put in a controller. All works great - retrieve, create, update, delete.
2. From Telerik menu, reconfigure to use KendoUI. Using 2012.2.710. (Separate note - if trying to upgrade to 2013.1.x.x - a breaking upgrade). Add an Admin and a Member area - routing seems to be working oK
3. Add Kendo Grid
@(Html.Kendo().Grid(Model).Name("KeysGrid")
.Columns(columns =>
{
columns.Bound(curkey => curkey.ID).Hidden();
columns.Bound(curkey => curkey.CreateStamp).Visible(false);
columns.Bound(curkey => curkey.OwnerAccountsID).Visible(false);
columns.Bound(curkey => curkey.ReplacedBy).Hidden();
columns.Bound(curkey => curkey.Name).Width("20%");
columns.Bound(curkey => curkey.Description).Width("60%");
columns.Command(cmd =>
{
cmd.Edit().HtmlAttributes(new { title = "edit this key" }).;
cmd.Destroy().HtmlAttributes(new { title = "delete this key" });
})
.Width("20%")
.Title("Commands")
.Width(75);
})
.ToolBar(toolBar => toolBar.Template(@"
<div>
<a onclick='createRow()' title='Create a new key' style='float:left;'> <img src='/Content/images/button_add_01.png' style='width:32px; height:32px; text-decoration:none; border:none;' /></a>
<a onclick='callHelp()' title='Help on keys' style='float:right;'><img src='/Content/images/button_info_01.png' style='width:32px; height:32px; text-decoration:none; border:none;' /></a>
</div>
"))
.Editable(editable => editable.Mode(GridEditMode.PopUp)
.TemplateName("AddEditKey").Window(w => w.Title("Add / Edit Keys")))
.Pageable(pages => pages.PageSizes(new int[] { 10, 20, 50 }))
.Resizable(p => p.Columns(true))
.Sortable()
.Selectable()
.Filterable()
.Scrollable(p => p.Enabled(false))
.Groupable(p => p.Enabled(false))
.DataSource(datasource => datasource
.Ajax()
.Events(e => e.Error("error_handler")
)
.Create(c => c.Action("Create", "YFKey", new { area="Member", controller="YFKey", action="Create" }))
.Update(c => c.Action("Edit", "YFKey", new { area="Member", controller="YFKey", action="Edit" }))
.Destroy(c => c.Action("Delete", "YFKey", new { area="Member", controller="YFKey", action="Delete" }))
)
)
4. Now when go to index page, grid shows data from underlying database. I edit grid, popup comes up with proper fields, edit data, save - popup goes away and changed fields marked with little red triangle - changes to underlying DB not made.
5. In Chrome, hit F12, look at network, it's getting a 500 Internal Server Error. All data from edit form looks proper - just not happening. Any ideas?
Autogenerated controller from database methods include:
[Authorize]
public ActionResult Edit(long id = 0)
{
YFKey yfkey = db.YFKeys.Find(id);
if (yfkey == null)
{
return HttpNotFound();
}
return View(yfkey);
}
//
// POST: /Member/YFKey/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(YFKey yfkey)
{
if (ModelState.IsValid)
{
db.Entry(yfkey).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(yfkey);
}
Note that at the same time, the auto created forms from the database first edmx file still work, and even on the same form.
Maybe obvious to me someday, but not today.
Thanks.
Chris
New to MVC4 and to Kendo. So probably some misconceptions. Tried for a couple days. Need suggestions.
1. Started Visual Studio 2012 new project using Asp.net mvc 4 web app. Connected to existing database with edmx file. Put in a controller. All works great - retrieve, create, update, delete.
2. From Telerik menu, reconfigure to use KendoUI. Using 2012.2.710. (Separate note - if trying to upgrade to 2013.1.x.x - a breaking upgrade). Add an Admin and a Member area - routing seems to be working oK
3. Add Kendo Grid
@(Html.Kendo().Grid(Model).Name("KeysGrid")
.Columns(columns =>
{
columns.Bound(curkey => curkey.ID).Hidden();
columns.Bound(curkey => curkey.CreateStamp).Visible(false);
columns.Bound(curkey => curkey.OwnerAccountsID).Visible(false);
columns.Bound(curkey => curkey.ReplacedBy).Hidden();
columns.Bound(curkey => curkey.Name).Width("20%");
columns.Bound(curkey => curkey.Description).Width("60%");
columns.Command(cmd =>
{
cmd.Edit().HtmlAttributes(new { title = "edit this key" }).;
cmd.Destroy().HtmlAttributes(new { title = "delete this key" });
})
.Width("20%")
.Title("Commands")
.Width(75);
})
.ToolBar(toolBar => toolBar.Template(@"
<div>
<a onclick='createRow()' title='Create a new key' style='float:left;'> <img src='/Content/images/button_add_01.png' style='width:32px; height:32px; text-decoration:none; border:none;' /></a>
<a onclick='callHelp()' title='Help on keys' style='float:right;'><img src='/Content/images/button_info_01.png' style='width:32px; height:32px; text-decoration:none; border:none;' /></a>
</div>
"))
.Editable(editable => editable.Mode(GridEditMode.PopUp)
.TemplateName("AddEditKey").Window(w => w.Title("Add / Edit Keys")))
.Pageable(pages => pages.PageSizes(new int[] { 10, 20, 50 }))
.Resizable(p => p.Columns(true))
.Sortable()
.Selectable()
.Filterable()
.Scrollable(p => p.Enabled(false))
.Groupable(p => p.Enabled(false))
.DataSource(datasource => datasource
.Ajax()
.Events(e => e.Error("error_handler")
)
.Create(c => c.Action("Create", "YFKey", new { area="Member", controller="YFKey", action="Create" }))
.Update(c => c.Action("Edit", "YFKey", new { area="Member", controller="YFKey", action="Edit" }))
.Destroy(c => c.Action("Delete", "YFKey", new { area="Member", controller="YFKey", action="Delete" }))
)
)
4. Now when go to index page, grid shows data from underlying database. I edit grid, popup comes up with proper fields, edit data, save - popup goes away and changed fields marked with little red triangle - changes to underlying DB not made.
5. In Chrome, hit F12, look at network, it's getting a 500 Internal Server Error. All data from edit form looks proper - just not happening. Any ideas?
Autogenerated controller from database methods include:
[Authorize]
public ActionResult Edit(long id = 0)
{
YFKey yfkey = db.YFKeys.Find(id);
if (yfkey == null)
{
return HttpNotFound();
}
return View(yfkey);
}
//
// POST: /Member/YFKey/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(YFKey yfkey)
{
if (ModelState.IsValid)
{
db.Entry(yfkey).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(yfkey);
}
Note that at the same time, the auto created forms from the database first edmx file still work, and even on the same form.
Maybe obvious to me someday, but not today.
Thanks.
Chris