This question is locked. New answers and comments are not allowed.
Hi there,
i was having problems using the telerik gridview with ajaxbinding on a partial view so i gave up after hours and decided to create a single view with a telerik gridview which uses ajaxbinding.
The grid data loads for the first time, and the ajax binding works (sorting, paging, etc) but ONLY if i don't add commands to the grid (If i add columns for editing, deleting or a toolbar to add items, the ajaxbinding is ignored (that's why i commented those lines in the code)
Here is my code:
Layout (masterpage)
View
Controller:
This is really odd, any ideas?
Thanks in advance
i was having problems using the telerik gridview with ajaxbinding on a partial view so i gave up after hours and decided to create a single view with a telerik gridview which uses ajaxbinding.
The grid data loads for the first time, and the ajax binding works (sorting, paging, etc) but ONLY if i don't add commands to the grid (If i add columns for editing, deleting or a toolbar to add items, the ajaxbinding is ignored (that's why i commented those lines in the code)
Here is my code:
Layout (masterpage)
<!DOCTYPE html>
<!-- All we need is the "doctype html" to force standards compliance -->
<
html
>
<
head
>
<
meta
http-equiv
=
"Expires"
content
=
"0"
/>
<
meta
http-equiv
=
"Pragma"
content
=
"no-cache"
/>
<
meta
http-equiv
=
"Cache-Control"
content
=
"no-cache"
/>
<
title
>@ViewBag.Title</
title
>
@using Telerik.Web.Mvc.UI
@( Html.Telerik().StyleSheetRegistrar()
.DefaultGroup(group => group.Add("telerik.common.css")
.Add("telerik.windows7.css")
.Add("css/iris/iris.jquery-ui.css")
.Add("css/style.css?v=2")
.Add("css/grid.css?v=1")
.Add("css/uniform.default.css?v=1")
.Add("css/iris/iris.jquery-ui.css?v=1")
.Add("Dashboard.css")
)
)
<
link
rel
=
"Stylesheet"
href
=
"../../Content/telerik.windows7.css"
/>
<
link
rel
=
"Stylesheet"
href
=
"../../Content/telerik.common.css"
/>
<
link
rel
=
"Stylesheet"
href
=
"../../Content/css/style.css"
/>
</
head
>
<
body
>
<
header
>
<
div
class
=
"paddingdiv2"
>
<
div
class
=
"clearfix"
id
=
"top-bar"
>
<
div
class
=
"container_16 clearfix"
>
<
div
class
=
"grid_4"
>
<
div
class
=
"top-logo"
></
div
>
</
div
>
<
div
class
=
"grid_12"
style
=
""
>
<
div
class
=
"user-information"
>
<
div
class
=
"signin-info-wrap"
>
<
div
class
=
"floating-mail-animate"
>
<
span
class
=
"white"
>2</
span
>
</
div
>
<
div
class
=
"floating-mail"
>
<
span
class
=
"white"
>2</
span
>
</
div
>
Signed in as <
span
class
=
"white bold"
>@User.Identity</
span
><
br
/>
<
span
class
=
"icon-mail"
>You have <
span
class
=
"white"
>2 new </
span
>messages<
br
/></
span
>
</
div
>
<
ul
id
=
"top-bar-buttons"
>
<
li
>
<
a
href
=
"/Account/Settings"
>Settings</
a
><
span
class
=
"divide"
> | </
span
>
</
li
>
<
li
>
<
a
href
=
"#"
>Inbox</
a
><
span
class
=
"divide"
> | </
span
>
</
li
>
<
li
>
<
a
href
=
"/Account/LogOff"
>Sign Out</
a
>
</
li
>
</
ul
>
</
div
>
</
div
>
</
div
>
</
div
>
<
div
class
=
"container_16 clearfix tab-border-bottom"
></
div
><
br
/>
</
div
>
</
header
>
@RenderBody()
@(Html.Telerik().ScriptRegistrar()
.DefaultGroup(group => group
.Add("~/Scripts/2011.1.315/telerik.common.min.js")
.Add("~/Scripts/2011.1.315/telerik.grid.js")
.Add("~/Scripts/2011.1.315/telerik.grid.filtering.js")
.Add("~/Scripts/2011.1.315/telerik.grid.grouping.js")
.Add("~/Scripts/2011.1.315/telerik.grid.editing.js")
.Add("~/Scripts/2011.1.315/telerik.grid.reordering.js")
.Add("~/Scripts/2011.1.315/telerik.list.min.js")
.Add("~/Scripts/2011.1.315/telerik.combobox.min.js")
.Add("~/Scripts/jquery-ui-1.8.6.custom.min.js")
.Add("~/Scripts/libs/jquery.uniform.min.js")
.Add("~/Scripts/2011.1.315/jquery.validate.min.js")
.Add("~/Scripts/2011.1.315/telerik.calendar.js")
.Add("~/Scripts/2011.1.315/telerik.datepicker.js")
.Add("~/Scripts/2011.1.315/telerik.textbox.js")
.Add("~/Scripts/jquery.ribbon.js")
.Add("~/Scripts/iris-checkbox.js")
.Add("~/Scripts/jquery.calculator.js")
.Compress(true))
)
</
body
>
</
html
>
View
@model List<
IRIS.Aurora.ClientModel.PlaceHolders.PlaceHolderModel
>
@{
ViewBag.Title = "PlaceHolderValueList";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<
h2
>PlaceHolderValueList</
h2
>
@(Html.Telerik().Grid(Model)
.Name("Grid")
.DataKeys(keys => keys.Add(c => c.Name))
.Editable(editing => editing.Mode(GridEditMode.PopUp))
//.ToolBar(commands => commands.Insert())
.Columns(columns =>
{
columns.Bound(o => o.Name).Width(100);
columns.Bound(o => o.ValidFrom).Width(100);
columns.Bound(o => o.ValidTo).Width(100);
columns.Bound(o => o.Value).Width(100);
columns.Bound(o => o.ValueType).Width(100);
//columns.Command(commands =>
//{
// commands.Delete();
// commands.Edit();
//}).Width(180).Title("Commands");
})
.DataBinding(dataBinding =>
{
dataBinding.Ajax()
.Update("_AjaxUpdatePlaceHolderValue","PlaceHolder")
.Insert("_AjaxInsertPlaceHolderValue","PlaceHolder")
.Delete("_AjaxDeletePlaceHolderValue", "PlaceHolder")
.Select("_AjaxPlaceHolderValueListByName", "PlaceHolder", new { placeHolderName = (int)ViewData["placeHolderName"] });
})
.Scrollable()
.Sortable()
.Selectable()
.Pageable(a => a.PageSize(10))
.Filterable()
.Footer(true)
)
Controller:
[GridAction]
public ActionResult _AjaxPlaceHolderValueListByName(IrisPlaceHolderRepository rep, int placeHolderId)
{
var placeHolderValues = rep.GetByID(placeHolderId).PlaceHolderValues;
return View(new GridModel(placeHolderValues));
}
public ActionResult PlaceHolderValueList(IrisPlaceHolderRepository rep, int placeHolderId)
{
ViewData["placeHolderName"] = placeHolderId;
var placeholderValues = rep.GetByID(placeHolderId).PlaceHolderValues;
return PartialView(placeholderValues);
}
This is really odd, any ideas?
Thanks in advance