Any luck on this? I can get a Grid to work properly on a Telerik Window when AJAX Binding is not used. (so Server binding)
When I use AJAX binding I start to get all sorts of weird errors.
Like Microsoft JScript runtime error: Object required
with the error at the line below within MicrosoftMvcValidation.js
formElement[Sys.Mvc.FormContext._formValidationTag] = this;
Here is the Controller
public ActionResult Index_BargeLog(int BargeId)
{
IEnumerable<BargeLogViewModel> blvms = from bargelog in _db.BargeLogs.Where(bl => bl.BargeId == BargeId) select (new BargeLogViewModel
{
BargeLogId = bargelog.BargeLogId,
BargeActivityDateTime = bargelog.BargeActivityDateTime,
BargeActivityName = bargelog.BargeActivityType.BargeActivityName
});
ViewData.Model = blvms;
ViewData["BargeId"] = BargeId;
return PartialView("~/Views/BargeLog/Edit_BargeLog.ascx");
}
[GridAction]
public ActionResult Index_BargeLog_Ajax(int BargeId)
{
IEnumerable<BargeLogViewModel> blvms = from bargelog in _db.BargeLogs.Where(bl => bl.BargeId == BargeId)
select (new BargeLogViewModel
{
BargeLogId = bargelog.BargeLogId,
BargeActivityDateTime = bargelog.BargeActivityDateTime,
BargeActivityName = bargelog.BargeActivityType.BargeActivityName
});
ViewData.Model = new GridModel(blvms);
ViewData["BargeId"] = BargeId;
return PartialView("~/Views/BargeLog/Edit_BargeLog.ascx");
}
Here is the Parent ASPX
<%= Html.Telerik().Window()
.Name("Window")
.LoadContentFrom("Index_BargeLog", "BargeLog", new {BargeId = ViewData["BargeId"]})
.Buttons(buttons => buttons.Refresh().Maximize().Close())
%>
Here is the Partial View (
Edit_BargeLog.ascx)
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<WebRole.ViewModels.BargeLogViewModel>>" %>
<%: Html.Telerik().Grid(Model)
.Name("BargeLogGrid")
.DataBinding(dataBinding => dataBinding
.Ajax()
.Select("Index_BargeLog_Ajax", "BargeLog", new { BargeId = ViewData["BargeId"] })
.Update("Edit_BargeLog", "BargeLog"))
.Columns(col =>
{
col.Bound(bat => bat.BargeLogId).Title("Barge Log ID");
col.Bound(bat => bat.BargeActivityDateTime).Title("Date & Time");
col.Bound(bat => bat.BargeActivityName).Title("Activity");
col.Command(cmd => cmd.Edit());
})
.Pageable()
.Sortable()
.DataKeys(keys =>
{ keys.Add(c => c.BargeLogId);
})
%>
I've also tried different variations of the above and have ran into the Error! The requested URL returned 500 - Internal Server Error.