Hi, I'm having an issue with inline editing, create with the kendo grid.
When I click on the "edit" button in the grid, instead of the row turning into edit mode, I am redirected to a bank view with Json data. The same thing happens when I click on the "create" button in the grid. If it helps to know, this view is actually a partial view that is injected via ajax and It displays fine..
I have tried a lot of different things, like checking that I have the required JS libraries, tweaking the grid configurations in my view, etc...
I'm sure there is something really small that is causing this behavior and I would appreciate it if anybody can help me with this..
The view:
The Controller actions:
When I click on the "edit" button in the grid, instead of the row turning into edit mode, I am redirected to a bank view with Json data. The same thing happens when I click on the "create" button in the grid. If it helps to know, this view is actually a partial view that is injected via ajax and It displays fine..
I have tried a lot of different things, like checking that I have the required JS libraries, tweaking the grid configurations in my view, etc...
I'm sure there is something really small that is causing this behavior and I would appreciate it if anybody can help me with this..
The view:
@model IEnumerable<
TOPS.IQ.ViewModels.Administration.WebInfoVM
>
@(Html.Kendo().Grid<
TOPS.IQ.ViewModels.Administration.WebInfoVM
>(Model)
.Name("grid")
.HtmlAttributes(new { style = "height: 280px;" })
.DataSource(dataSource =>
dataSource.Ajax()
.Read(read => read.Action("EditingInlineWebInfo_Read", "Administration", new { id = Model.FirstOrDefault() == null ? 0 : Model.First().CommunityID }))
.Model(model => model.Id(m => m.WebInfoID))
.Create(update => update.Action("EditingInlineWebInfo_Create", "Administration"))
.Update(update => update.Action("EditingInlineWebInfo_Update", "Administration"))
.Destroy(update => update.Action("EditingInlineWebInfo_Destroy", "Administration"))
)
.Columns(columns =>
{
columns.Bound(p => p.WebInfoTypeName);
columns.Bound(p => p.Email);
columns.Bound(p => p.Description);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
})
.ToolBar(toolbar => toolbar.Create())
.Editable()
.Pageable()
.Sortable()
.Scrollable()
)
The Controller actions:
public
JsonResult EditingInlineWebInfo_Read([DataSourceRequest] DataSourceRequest request,
int
id)
{
//get the web infos for the given community
var webInfos = _service.FindAll<Community_Webaddress>().Where(c => c.CommunityID == id).Select(c => c.WebAddress);
var webInfosVM = webInfos.ConvertToWebInfoesVM();
return
Json(webInfosVM.ToDataSourceResult(request),JsonRequestBehavior.AllowGet);
}
[HttpPost]
public
ActionResult EditingInlineWebInfo_Create([DataSourceRequest] DataSourceRequest request, WebInfoVM webVM)
{
if
(webVM !=
null
&& ModelState.IsValid)
{
var webAddr = webVM.ConvertToWebAddress();
_service.Add<WebAddress>(webAddr);
var task = _service.SaveChangesAsync();
int
result = task.Result;
}
return
Json(
new
[] { webVM }.ToDataSourceResult(request, ModelState));
}
[HttpPost]
public
ActionResult EditingInlineWebInfo_Update([DataSourceRequest] DataSourceRequest request, WebInfoVM webVM)
{
if
(webVM !=
null
&& ModelState.IsValid)
{
var webAddr = webVM.ConvertToWebAddress();
var task = _service.SaveChangesAsync();
int
result = task.Result;
}
return
Json(
new
[] { webVM }.ToDataSourceResult(request, ModelState));
}