We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Hierarchical not displaying

Thread ID:

Created:

Updated:

Platform:

Replies:

130229 Apr 29,2017 04:21 PM May 4,2017 05:34 AM ASP.NET MVC 3
loading
Tags: Grid
Chris Erickson
Asked On April 29, 2017 04:21 PM

Hi all,

I am attempting to implement a Hierarchical grid.  The main grid is rendering correctly and the child datasource is firing off and returning the correct json. I think the problem lies in when it tries to bind to the grid itself. I keep getting an error:

SCRIPT5007: Unable to get property 'length' of undefined or null reference
ej.web.all.min.js (10,3028908)

I think the last time I had a problem like this was due to a root being declared but I can't remember if it was with this toolset or not.

Here is the razor:
 @(Html.EJ().Grid<WhoIsHotViewModel>("Grid")
            .Datasource(whoIsHot)
            .Columns(col =>
            {
                col.Field(p => p.PlayerId).HeaderText("PlayerId").Visible(true);
                col.Field(p => p.Wins).HeaderText("Wins").TextAlign(TextAlign.Left).Add();
                col.Field(p => p.FullName).HeaderText("Player").TextAlign(TextAlign.Left).Add();
                col.Field(p => p.Region).HeaderText("Region").TextAlign(TextAlign.Left).Add();
            })
             .ChildGrid(child =>
             {
                 child.Datasource(Url.Action("GetHotPlayerDetails"))
                    .QueryString("PlayerId")
                    .AllowPaging(false)
                    .PageSettings(page => page.PageSize(20))
                    .Columns(col =>
                    {
                        col.Field("PlayerId").Visible(true).HeaderText("PlayerId").Add();
                        col.Field("WinId").Visible(true).HeaderText("WinId").Add();
                        col.Field("WinDate").HeaderText("Date").TextAlign(TextAlign.Right).Width(75).Add();
                        col.Field("VenueName").HeaderText("VenueName").Width(100).Add();
                        col.Field("WinType").HeaderText("Win Type").Width(120).Add();
                        col.Field("GameNumber").HeaderText("Game Number").Width(100).Add();
                    });
             })
            .IsResponsive(true))

Here is the controller:
public ActionResult GetHotPlayerDetails()
        {
            Char delimiter = '\'';
            string[] filter = Request.QueryString["$filter"].Split(delimiter);
            var results = wgf.GetPlayerWins(DateTime.Now.AddDays(-7), DateTime.Now, filter[1]);
            return Json(results, JsonRequestBehavior.AllowGet);
        }

Oh as a side note, I would really prefer not using request.querystring so how to correctly tie the Url.Action to the child datasource would be appreciated.

Here is a resulting Json sample:
[
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "20ea0e37-ba34-4ddb-9625-0713aa7b5dc3",
        "WinDate": "/Date(1493092800000)/",
        "VenueName": "Duffy's Sports Grill of Waterford Lakes-DBKC Seat",
        "WinType": "Other",
        "GameNumber": 2
    },
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "6ed1c7b4-678e-41a2-8d0c-4d587ebe32db",
        "WinDate": "/Date(1493092800000)/",
        "VenueName": "Duffy's Sports Grill of Waterford Lakes-DBKC Seat",
        "WinType": "Win",
        "GameNumber": 9
    },
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "db410089-480c-47fc-8547-c7d7f60d38a4",
        "WinDate": "/Date(1493092800000)/",
        "VenueName": "Duffy's Sports Grill of Waterford Lakes-DBKC Seat",
        "WinType": "Other",
        "GameNumber": 2
    },
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "20f1945a-726d-4cbf-99be-870bb7ae279a",
        "WinDate": "/Date(1493006400000)/",
        "VenueName": "Firkin & Kegler",
        "WinType": "Win",
        "GameNumber": 6
    },
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "756e3430-ccfd-4d2b-bc52-8e786e1a9afd",
        "WinDate": "/Date(1493006400000)/",
        "VenueName": "Firkin & Kegler",
        "WinType": "Other",
        "GameNumber": 4
    },
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "b020635a-eaf1-4ece-98b6-a9cbf366591e",
        "WinDate": "/Date(1493006400000)/",
        "VenueName": "Firkin & Kegler",
        "WinType": "Win",
        "GameNumber": 4
    },
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "c90ac25d-92ca-4368-b4d5-d11034867c63",
        "WinDate": "/Date(1493006400000)/",
        "VenueName": "Firkin & Kegler",
        "WinType": "Other",
        "GameNumber": 4
    },
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "b1774eaa-afd8-4fc0-ab0a-58705d4982f4",
        "WinDate": "/Date(1492920000000)/",
        "VenueName": "East Coast Wings & Grill -DBKC Seat",
        "WinType": "Win",
        "GameNumber": 3
    },
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "0a6881c3-9361-48e5-acf2-65ce235ce22f",
        "WinDate": "/Date(1492920000000)/",
        "VenueName": "East Coast Wings & Grill -DBKC Seat",
        "WinType": "Other",
        "GameNumber": 3
    },
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "b682d52d-d434-4b5f-b371-753b8e8a83b7",
        "WinDate": "/Date(1492920000000)/",
        "VenueName": "East Coast Wings & Grill -DBKC Seat",
        "WinType": "Other",
        "GameNumber": 3
    },
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "7f88ac50-08e7-47ee-bb33-8d7527de62d3",
        "WinDate": "/Date(1492920000000)/",
        "VenueName": "East Coast Wings & Grill -DBKC Seat",
        "WinType": "Win",
        "GameNumber": 5
    },
    {
        "PlayerId": "8e962ee3-d3b7-4684-87d0-a48d00df87ca",
        "WinId": "e3eb2b34-9ca8-4f8c-9284-9074a52ea052",
        "WinDate": "/Date(1492920000000)/",
        "VenueName": "East Coast Wings & Grill -DBKC Seat",
        "WinType": "Win",
        "GameNumber": 7
    }
]

As always thank you in advance and any help would be appreciated.

Thanks,
Chris



Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On May 1, 2017 02:55 AM

Hi Chris,  
 
Thanks for contacting Syncfusion Support.  
 
We can reproduce the problem at our end. The cause of the problem is, the controller action is not returning the results as result/count pair. To handle the controller actions in the Grid is using the UrlAdaptor of the ej.DataManager. Refer to the following Help Document. 
 
 
Please make a note, resultant object from the server must be wrapped with the result/count pair as shown in the following code example. 
 
        public ActionResult DataSource(DataManager dm) 
        { 
            IEnumerable data = OrderData; 
            DataOperations operation = new DataOperations(); 
            . . . 
                 . . .  
            return Json(new { result = data, count = count }); 
        } 
 
Refer to the following KB for the Data Operations in the server end.  
 
 
Regards,  
Seeni Sakthi Kumar S. 
 
 


Chris Erickson
Replied On May 3, 2017 11:42 AM

Thank you! I figured it was something simple like that.

Jayaprakash Kamaraj [Syncfusion]
Replied On May 4, 2017 05:34 AM

Hi Chris,  
 
Thanks for the update. 
 
Please get back to us if you need any further assistance.   
 
Regards,  
 
Jayaprakash K. 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;