Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Window > Grid on Window not working

Not answered Grid on Window not working

Feed from this thread
  • Alex avatar

    Posted on Jul 26, 2010 (permalink)

    Hi I was trying to create a new Window which loads its contents from an aspx page which contains Telerik's Grid...the window shows but the grid is not making the ajax call to grab the data...

    The window code is on a page based on a masterpage which has the call to ScriptRegistrar...the aspx being loaded in the window is just a plain aspx with no masterpage...could this be a problem with script registration? or do I have to set/call scriptregistrar also in the aspx page?

    Any ideas?

    Thank you!!!

            <%= Html.Telerik().Window()
                .Name("NewCustomer")
                .Animation(true)
                .LoadContentFrom("ShowCustomerWindow", "Customer")
                .Buttons(buttons => buttons.Close())
                .Draggable(true)
                .Modal(true)
                .Title("Add Customer")
                .Visible(false)
            %>

    Reply

  • Georgi Krustev Georgi Krustev admin's avatar

    Posted on Jul 27, 2010 (permalink)

    Hello Alex,

    LoadContentFrom method uses MS Ajax to render provided partial view. As you probably no the javascript files will not be evaluated in this case. That is why you need to add them by hand. You can check these two help topics for more information:
    http://www.telerik.com/help/aspnet-mvc/using-with-partial-views-loaded-via-ajax.html
    http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-required-javascript-files.html

    Kind regards,
    Georgi Krustev
    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

    Reply

  • Alonzo avatar

    Posted on Aug 4, 2010 (permalink)

     Hi Georgi, I am new to this libraries and tried to implement something like this on a project following the links you posted but with no success, do you think you can setup a small project with a window with a grid inside that works? Thank you very much!!!

    Reply

  • Bill avatar

    Posted on Aug 30, 2010 (permalink)

    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.


    Reply

  • Bill avatar

    Posted on Aug 30, 2010 (permalink)

    It looks like this is just an IE (8) issue. In Firefox, I am able to load a Grid within a Telerik Window using AJAX binding without any jscript errors popping up. However, the contents of the modal Window is displayed as an ASPX page as soon as I click the edit button.

    Reply

  • Atanas Korchev Atanas Korchev admin's avatar

    Posted on Aug 31, 2010 (permalink)

    Hi Bill,

    We cannot reproduce this problem locally. Could you please send us a sample project? Since the forum allows only image attachments you can use a public file sharing service such as dropbox.com or skydrive.live.com.

    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

    Reply

  • Bill avatar

    Posted on Sep 1, 2010 (permalink)

    I probably won't need a sample project after I explain further. The real problem is really an Object Required Jscript error with the file MicrosoftMvcValidation.js and the Telerik MVC grid. The problem happens with or without the use of a Telerik Window.

    If I remove the line below from the js file the Object Required error goes away. Snippet
    Sys.Mvc.FormContext._Application_Load()

    I am referencing the following files below in my master page to achieve client side validation using Data Annotations and an Entity Framework model.

    Snippet
        <script src="<%= Url.Content("~/Scripts/MicrosoftAjax.js") %>" type="text/javascript"></script>
         <script src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.js") %>" type="text/javascript"></script>
         <script src="<%= Url.Content("~/Scripts/MicrosoftMvcValidation.js") %>" type="text/javascript"></script>   

    Also, I assume this reason this only happens in IE and not Firefox is because of some IE JavaScript setting. The jscript error does not occur in FireFox but the client side validation stops working.

    This really belongs in the Grid area of the forum so I'll post a more detailed message there.

    Reply

  • Craig Fisher avatar

    Posted on Feb 2, 2011 (permalink)

    I'd like to second that request for a sample project.
    I'm having the same sort of problem: I have a Window that is created via client side code and populated from a View via the contenturl property. The view contains a grid that is configured to do AJAX binding. The AJAX request is never excuted though.
    The same grid works fine if it is on the parent View, just not if it is in the Window.

    Reply

  • Atanas Korchev Atanas Korchev admin's avatar

    Posted on Feb 3, 2011 (permalink)

    Hi Craig Fisher,

     Most probably the JavaScript files needed by the grid are not loaded. Please check this help article for additional reference.

    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

    Reply

  • Craig Fisher avatar

    Posted on Feb 3, 2011 (permalink)

    Thanks for your response Atanas.

    I found the instructions on that page a bit confusing because I'm not using a partial view. The Window content is populated from a View page.
    When I have a grid on the parent page, the grid in the Window works properly (it does Ajax requests). That suggests to me that it probably is a problem with the grid in the Window not having access to the scripts. But if it is being loaded from a View rather than a partial view wouldn't the scripts be registered automatically? (Actually, it only works properly the first time the Window is opened, the second time it doesn't - refreshing the grid doesn't do an Ajax request. Not sure why that would be. ??)
    Do I have to load the Window content from a partial view?
    I'm creating the Window on the client side like this:

    var
    windowElement = $.telerik.window.create({
     name:
    "LookupWindow",
     title:
    "Code Lookup",
     contentUrl: '/Portal/Lookup',
     modal: true,
     resizable:
    true,
     draggable:
    true,
     width: 500,
     height: 350
    });

     

     

     

    Reply

  • Craig Fisher avatar

    Posted on Feb 3, 2011 (permalink)

    Update: OK, I found that adding this line to the view that populates the Window makes the grid do an Ajax request to fetch the data.

     

    <script type="text/javascript" src="/Portal/Scripts/2010.3.1318/telerik.grid.min.js" />

     

    I still have the problem though that the second time the Window is opened, it doesn't do any Ajax requests. Clicking on any of the controls that update the grid (refresh, next page) causes the browser to go to the URL that fetches that data.

    Reply

  • Atanas Korchev Atanas Korchev admin's avatar

    Posted on Feb 4, 2011 (permalink)

    Hello Craig Fisher,

     I am not sure what the problem may be. Please attach a sample application demonstrating your issue.

    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

    Reply

  • Craig Fisher avatar

    Posted on Feb 4, 2011 (permalink)

    I found the solution to this problem in a related thread: http://www.telerik.com/community/forums/aspnet-mvc/window/modal-property-not-working-on-second-open.aspx

    This fix is to destroy the Window object in the onClose handler.

    Reply

  • Matt Cowen avatar

    Posted on Nov 26, 2011 (permalink)

    I'm also having an issue with an AJAX custom bound grid in a window. I have a column with a ClientTemplate but no matter what I put in there the text just never shows up. I've used the same markup in a normal view with no problems. The markup for the grid is done inline using Window.Content() etc.

    Reply

  • Petur Subev Petur Subev admin's avatar

    Posted on Nov 29, 2011 (permalink)

    Hello Matt Cowen,

    When you set the Content of the Window please make sure you use the @<text>...</text> Razor syntax correctly.
    e.g.

    @(Html.Telerik().Window()
        .Name("GridWindow")
        .Title("Grid Inside Window")
        .Width(350)
        .Height(400)
        .Content(
            @<text>
                @(Html.Telerik().Grid<Person>()
                .Name("Grid")
                .DataBinding(binding => binding.Ajax().Select("GetPersons", "Grid"))
                    .Columns(columns =>
                    {
                        columns.AutoGenerate(true);
                        columns.Bound(p => p.Name).ClientTemplate("<strong><#= Name #></strong>").Title("Client Templated");
                    })
                )
            </text>
        )
    )

    For your convenience I attached a sample project which implements the scenario with a Grid using Ajax Binding and a Client Template column inside a Window.

    Kind regards,
    Petur Subev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
    Attached files

    Reply

  • Matt Cowen avatar

    Posted on Nov 29, 2011 (permalink)

    Thanks Petur, however I'm using traditional ASPX views rather than Razor.

    I was setting the content inline but changed it to use a PartialView, neither way worked but I would like to use a partial view for maintainability:

    .Content(() => Html.RenderPartial("FindChild"))

    Here's what my Grid code in the view looked like:

    <% Html.Telerik().Grid<App.Core.QueryDtos.ChildDto>()
            .DataKeys(k => k.Add(c => c.Id))
            .Name("FindChildrenGrid")
            .Columns(columns => {
                columns.Command(commands => commands.Select()).Title("Select");
                columns
                .Template(c => {               
                        %>
                            <%=Html.ActionLink<ParentsController>(x => x.AddChild(1, c.Id), "Select")%>
                        <%
                })
                    .ClientTemplate("<a href='" + Url.Action("AddChild", "Parents") + "/<# Id #>'>Select</a>")
                    .Title("Select");
                columns.Bound(c => c.Forename).HeaderHtmlAttributes(new { @class = "name-column" });
                columns.Bound(c => c.Surname).HeaderHtmlAttributes(new { @class = "email-column" });
            })
        .DataBinding(dataBinding => dataBinding.Ajax().Select("Find", "Children"))
        .ClientEvents(x => x.OnDataBinding("onDataBinding"))
        .ClientEvents(x => x.OnRowSelect("onRowSelect"))
        .Pageable(settings => settings
            .Total((int)ViewData["total"]))
        .EnableCustomBinding(true)
        .Sortable(sorting => sorting
            .OrderBy(sortOrder => sortOrder.Add(c => c.Surname).Ascending()))
        .RowAction(row => row.Selected = row.DataItem.Id.Equals(ViewData["id"]))
        .Render();

    Reply

  • Petur Subev Petur Subev admin's avatar

    Posted on Nov 30, 2011 (permalink)

    Hello Matt Cowen,

    I recreated the scenario using the ASPX view engine and there is no difference in the behavior.
    Could you please check the project I attached? If I missed something please modify the project and send it back so I can examine it.

    Regards,
    Petur Subev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now

    Reply

  • solomon avatar

    Posted on Feb 20, 2012 (permalink)

    Name conflicts may cause that. Try any arbitrary name on grid.

    Reply

  • Jose Arevalo avatar

    Posted on Jun 1, 2012 (permalink)

    Thanks so much!! That was the problem that I was having.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Window > Grid on Window not working
Related resources for "Grid on Window not working"

ASP.NET MVC Window Features  |  Documentation  |  Demos  |  Telerik TV ]