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

[Solved] An internal 500 error thrown when try to play the related grid sample

8 Answers 140 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.
ady zhu
Top achievements
Rank 1
ady zhu asked on 18 Nov 2009, 05:36 AM
I tried to play around the related grid and here is my sample code
At Controller

 public partial class CPRScrumController : Controller
    {
        public ActionResult ViewScrumNotes()
        {
            ViewData["CPRScrumNote"] = GetScrumNote();
            ViewData["CPRs"] = GetCPRForScrumNote("222181");

            return View(GetScrumNote());
        }

        [GridAction]
        public ActionResult _ViewScrumNotes_CPRs(string cprID)
        {
            cprID = cprID ?? "222181";

            return View(new GridModel<VantiveCPR>
            {
                Data = GetCPRForScrumNote(cprID)
            });
        }

        [GridAction]
        public ActionResult _ViewScrumNotes_ScrumNotes()
        {
            return View(new GridModel<SYS2CPRScrumNote>
            {
                Data = GetScrumNote()
            });
        }

    }

At View:

<%= Html.Telerik().Grid<SYSIISCRUM.Models.SYS2CPRScrumNote>()
        .Name("CPRScrumNotes")
        .Columns(columns =>
        {
            
            columns.Add(c => c.ScrumCPRID).Width(20);
            columns.Add(c => c.ScrumCPRTitle).Width(200);
            columns.Add(c => c.ScrumDate).Width(100).Format("{0:dd/MM/yyyy}");
            columns.Add(c => c.ScrumTest).Width(200);
            columns.Add(c => c.ScrumDev).Width(200);
            columns.Add(c => c.ScrumTeam).Width(200);
            columns.Add(c => c.ScrumNotes).Width(200);
            columns.Add(c => c.ScrumCPRProduct).Width(200);
            columns.Add(c => c.ScrumCPRPriority).Width(200);
        })
        .Ajax(ajax => ajax.Action("_ViewScrumNotes_ScrumNotes", "CPRScrum"))
        .Pageable()
        .Sortable()
        .Filterable()
        .RowAction(row =>
        {
            if (row.DataItem.ScrumCPRID == "222181")
            {
                row.HtmlAttributes["class"] = "t-state-selected";
            }
        })
        .BindTo((IEnumerable<SYSIISCRUM.Models.SYS2CPRScrumNote>)ViewData["CPRScrumNote"])
%>

<h3>CPRS (<span id="cprID">222181</span>)</h3>

<%= Html.Telerik().Grid<SYSIISCRUM.Models.VantiveCPR>()
        .Name("CPRs")
        .Columns(columns=>
        {
            columns.Add(c => c.CPRID).Width(100);
            columns.Add(c => c.CPRTitle).Width(100);
            columns.Add(c => c.CPRCreateDate).Width(200).Format("{0:dd/MM/yyyy}");
            columns.Add(c => c.CPRComponent);
            columns.Add(c => c.CPRFeature).Width(200);
            columns.Add(c => c.CPRDescription);
        })
        .Pageable()
        .Sortable()
        .Ajax(ajax => ajax.Action("_ViewScrumNotes_CPRs", "CPRScrum", new { CPRID = "222181" }))
            .BindTo((IEnumerable<SYSIISCRUM.Models.VantiveCPR>)ViewData["CPRs"])
%>

<%
    Html.Telerik().ScriptRegistrar()
        .OnDocumentReady(() => 
        {
            %>
            var cprsGrid = $('#CPRs').data('tGrid');

            $('#CPRScrumNotes tbody tr')
                .live("click", function() {
                    // `this` == clicked row

                    var cprID = this.cells[0].innerHTML; 

                    // add selected style to clicked row
                    $(this).addClass('t-state-selected')
                           .siblings()
                           .removeClass('t-state-selected');

                    // update ui text
                    $('#cprID').text(cprID);

                    // rebind the related grid
                    cprsGrid.rebind({
                        CPRID: cprID
                    });
                })
                /* add hover effects */
                .live("mouseenter", $.telerik.hover)
                .live("mouseleave", $.telerik.leave);
        <% 
        });
%>

Initial view shows fine, but when i try to refresh the main grid (scrum notes) or child grid (cpr) or click on the one row of the main grid, i got internal server error of 500 thrown by the _ViewScrumNotes_ScrumNotes and _ViewScrumNotes_CPRs.

What is the possible reason i got this type of error?

thx


8 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 18 Nov 2009, 02:48 PM
Hi ady zhu,

Because 500 error is general error for server error it is hard to determine where could be the problem.
I will suggest you use firebug or other tool to debug and view what actually error 500 means. The error text is returned in the Response.

Best wishes,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
ady zhu
Top achievements
Rank 1
answered on 18 Nov 2009, 03:55 PM
I think i narrow down the issue a little bit.

When i try to go tot he URL http://localhost/CPRScrum/_ViewScrumNotes_CPRs?CPRid=202345 and i got back complaining that it cannot find a corresponding view for it.

How does the RelatedGrid example deal with this for the _RelatedGrids_Customers and _RelatedGrids_Orders actionresult?

thx

Andy
0
Alex Gyoshev
Telerik team
answered on 19 Nov 2009, 12:34 PM
Hello ady zhu,

Both these actions need the [GridAction] attribute - otherwise, they throw the same error 500 (I just tried it with the demo site). Can you please verify that you have this attribute on both methods?

Greetings,
Alex
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
ady zhu
Top achievements
Rank 1
answered on 24 Nov 2009, 03:58 AM
If you look at my code snippe, i do have [GridAction] attribute set for my action
0
Georgi Krustev
Telerik team
answered on 25 Nov 2009, 02:00 PM
Hi ady zhu,

The described behavior is expected, because the action method returns view and there is no corresponding page with the same name. The error 500 could be produced when circular reference is detected when the IEnumerable collection is serialized.

Nevertheless I am not able to advice you further without the text of the error returned from the server. As I mentioned earlier in this thread you can use Fiddler or Firebug and investigate the response of the problematic request. In the response header you can find the required text which describes what 500 error actually means.

Sincerely yours,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Flame Boy
Top achievements
Rank 1
answered on 04 Dec 2009, 09:56 AM
I was having this exact same problem. The grid was giving me a 500 error, and the debug complained that it could not find the _AjaxBinding view even though I had the [GridAction] attribute there.

I believe this is because of what you said - there were circular relationships in the Linq entities I was trying to bind to. The way I fixed this was to add the GridWithAnonimousTypes extension method and use it to bind to explicit properties via anonymous type.

Is there any other way to get around this? Using anonymous types all the time is fairly annoying, and I'm losing type safety.

Am I just constructing my database poorly? Any advice would be appreciated.
0
Atanas Korchev
Telerik team
answered on 04 Dec 2009, 01:07 PM
Hello Flame Boy,

To avoid circular reference problems you can use ViewModel classes. Check this blog post for additional info.

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Flame Boy
Top achievements
Rank 1
answered on 05 Dec 2009, 01:59 AM
Very helpful, thanks for the quick response.You guys are doing great with this product, keep up the good work!
Tags
Grid
Asked by
ady zhu
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
ady zhu
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Flame Boy
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or