This is a migrated thread and some comments may be shown as answers.

Ajax binding ignored

3 Answers 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pablo
Top achievements
Rank 1
Pablo asked on 05 May 2011, 04:59 PM
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)
<!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

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 06 May 2011, 06:37 AM
Hello Pablo,

 Please try moving the grid javascript file to be registered last in your script registrar definition. As outlined in the required JavaScript files help topic the grid relies on other JavaScript files when editing is enabled.

Best wishes,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Pablo
Top achievements
Rank 1
answered on 06 May 2011, 10:20 AM
Hi Atanas,

unfortunately that has not fixed my problem, it doesn't make any difference. I paste the new code in my layout page, where i register the scripts:
<!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()
               
 
    @* LOAD TELERIK COMMON FIRST! Otherwise you will regret it. *@
 
    @(Html.Telerik().ScriptRegistrar()
                     .DefaultGroup(group => group
                        .Add("~/Scripts/2011.1.315/telerik.common.min.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-1.5.1.min.js")
                        .Add("~/Scripts/2011.1.315/jquery.validate.min.js")
                        .Add("~/Scripts/2011.1.315/telerik.calendar.min.js")
                        .Add("~/Scripts/2011.1.315/telerik.datepicker.min.js")
                        .Add("~/Scripts/2011.1.315/telerik.textbox.min.js")
                        .Add("~/Scripts/2011.1.315/telerik.grid.min.js")
                        .Add("~/Scripts/2011.1.315/telerik.draganddrop.min.js")
                        .Add("~/Scripts/2011.1.315/telerik.grid.grouping.min.js")
                        .Add("~/Scripts/2011.1.315/telerik.grid.filtering.min.js")
                        .Add("~/Scripts/2011.1.315/telerik.grid.resizing.min.js")
                        .Add("~/Scripts/2011.1.315/telerik.grid.reordering.min.js")
                        .Add("~/Scripts/2011.1.315/telerik.grid.editing.min.js")                       
                        .Compress(true))
    )
</body>
</html>

Also, if I try to use a telerik datepicker, it doesn't work ...

Thanks in advance
0
Atanas Korchev
Telerik team
answered on 06 May 2011, 10:38 AM
Hello Pablo,

 Unfortunately I am out of ideas. Is there a chance to attach a runnable version of your project? I think there is something else which prevents the grid from working.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Pablo
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Pablo
Top achievements
Rank 1
Share this question
or