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

[Solved] adding commands messes up ajax.beginform outside of grid

1 Answer 83 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.
Phil
Top achievements
Rank 1
Phil asked on 31 May 2012, 08:57 PM
I have a telerik MVC grid that i'm trying to add editing to.  Basically, it exists in a partial view and has the following:
        Html.Telerik().Grid<DGI.CoBRA.Web.BusinessObjects.FullLogEntry>(Model)
.Name("loggrid")
.DataKeys(keys =>
{
    keys.Add(p => p.LogEntryGUID).RouteKey("LogEntryGUID");
})
.Columns(columns =>
{
    columns.Bound(o => o.FriendlyUserName ).Width(120).Title("User");
    columns.Bound(o => o.EventDescription).Template(@<text>
    @if (item.Priority == DGI.CoBRAPlugInSDK.LogPriority.High)
    {
        <span style="color: #FF0000">@item.EventDescription</span>
    }
    else
    {
        <span>@item.EventDescription</span>
    }
    </text>
            )
            .ClientTemplate("<# if (Priority==30) {#>" +
            "<span style='color: #FF0000'><#=EventDescription#></span>" +
        " <#} else {#>" +
        "<span><#=EventDescription#></span>" +
        " <#}#>");
    columns.Bound(o => o.FormattedDateCreated).Width(120).Title("Date Created");
})
.DataBinding(dataBinding =>
{
    dataBinding.Ajax().OperationMode(GridOperationMode.Client)
        .Update("_UpdateLogEntry", "Notes", new { area = "Tools", id = @Model.ProjectGUID })
        .Delete("_DeleteLogEntry", "Notes", new { area = "Tools", id = @Model.ProjectGUID })
        .Select("_GetLogList", "Notes", new { area = "Tools", id = @Model.ProjectGUID });
}
                )
                .ClientEvents(events => events.OnRowDataBound("onRowDataBound"))
.Scrollable(scrolling => scrolling.Enabled(false))
.Sortable(sorting => sorting.Enabled(true))//.OrderBy(order =>order.Add(o => o.DateCreated)))
.Pageable(paging => paging.Enabled(true))
.Filterable(filtering => filtering.Enabled(true))
.Groupable(grouping => grouping.Enabled(false))
.Footer(true)
.Render();
This code works GREAT.  I also have a way to insert new data that is outside of the grid (necesary for my purposes).  This is an Ajax.BeginForm that is in the parent layout:
@using (Ajax.BeginForm("AddNewNote","Notes", new AjaxOptions { InsertionMode = InsertionMode.Replace, HttpMethod = "POST", UpdateTargetId = "divnotelist", OnBegin = "StartProg", OnComplete = "StopProg" }))
{
    <script type="text/javascript">
        function StartProg() {
            $('#progressbar').show();
        }
        function StopProg() {
            $('#progressbar').hide();
            $('#NewNoteText').val('');
            $("#NewNoteText").focus();
        }   
    </script>
    <div id="newnote" style="text-align: center;">
        <p>
            @Html.HiddenFor(m => m.ProjectGUID)
            <span class="editor-field">@Html.TextBox("NewNoteText",null, new { spellcheck = "true"})</span>   <span class="editor-label">High Priority:</span> <span class="editor-field">@Html.CheckBox("HighPriority")</span>
            <input type="submit" value="Add" /></p>
    </div>
}
Simple stuff.  This works GREAT too, no problems. 
The only issue is when i try to add a command.  Changing the grid code to :
        Html.Telerik().Grid<DGI.CoBRA.Web.BusinessObjects.FullLogEntry>(Model)
.Name("loggrid")
.DataKeys(keys =>
{
    keys.Add(p => p.LogEntryGUID).RouteKey("LogEntryGUID");
})
.Columns(columns =>
{
    columns.Bound(o => o.FriendlyUserName ).Width(120).Title("User");
    columns.Bound(o => o.EventDescription).Template(@<text>
    @if (item.Priority == DGI.CoBRAPlugInSDK.LogPriority.High)
    {
        <span style="color: #FF0000">@item.EventDescription</span>
    }
    else
    {
        <span>@item.EventDescription</span>
    }
    </text>
            )
            .ClientTemplate("<# if (Priority==30) {#>" +
            "<span style='color: #FF0000'><#=EventDescription#></span>" +
        " <#} else {#>" +
        "<span><#=EventDescription#></span>" +
        " <#}#>");
    columns.Bound(o => o.FormattedDateCreated).Width(120).Title("Date Created");
    columns.Command(c =>
        {
            c.Delete().ButtonType(GridButtonType.ImageAndText);
        }).IncludeInContextMenu(false).Width(35);
})
.DataBinding(dataBinding =>
{
    dataBinding.Ajax().OperationMode(GridOperationMode.Client)
        .Update("_UpdateLogEntry", "Notes", new { area = "Tools", id = @Model.ProjectGUID })
        .Delete("_DeleteLogEntry", "Notes", new { area = "Tools", id = @Model.ProjectGUID })
        .Select("_GetLogList", "Notes", new { area = "Tools", id = @Model.ProjectGUID });
}
                )
                .ClientEvents(events => events.OnRowDataBound("onRowDataBound"))
.Scrollable(scrolling => scrolling.Enabled(false))
.Sortable(sorting => sorting.Enabled(true))//.OrderBy(order =>order.Add(o => o.DateCreated)))
.Pageable(paging => paging.Enabled(true))
.Filterable(filtering => filtering.Enabled(true))
.Groupable(grouping => grouping.Enabled(false))
.Footer(true)
.Render();
Note, ALL i did was add a delete command.  now the grid works great still, the delete works good, but my ajax.beginform is broken.  when i click on the submit button in my ajax.beginform, i get 2 javascript errors, both the same:
c.validator.methods[e] is undefined

Now, if i use a custom command it doesn't break anything, but I don't like that solution because it doesn't help me when i try for 'Edit' (which breaks my ajax beginform as well). 

Why is the grid breaking my ajax.beginform?

1 Answer, 1 is accepted

Sort by
0
Phil
Top achievements
Rank 1
answered on 18 Jun 2012, 02:19 AM
Never got any sort of response to this, but it looks like the 2012.2.607 update fixed this issue.
Tags
Grid
Asked by
Phil
Top achievements
Rank 1
Answers by
Phil
Top achievements
Rank 1
Share this question
or