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. Image for the cookie policy date

Hierarchical not displaying

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



3 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team May 1, 2017 06:55 AM UTC

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. 
 
 



CE Chris Erickson May 3, 2017 03:42 PM UTC

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


JK Jayaprakash Kamaraj Syncfusion Team May 4, 2017 09:34 AM UTC

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


Loader.
Live Chat Icon For mobile
Up arrow icon