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

HierarchyGrid

going through a learning curve of Syncfusion controls, having an issue with child data not showing

Controller:
  var leagues = db.vwLeagues.ToList();
            ViewBag.datasource = leagues;

            var teams = db.vwTeamLists.ToList();
            ViewBag.datasourcechild = teams;
            return View();
View:

@(Html.EJ().Grid<vwLeague>("leagues")
                .Datasource((IEnumerable<vwLeague>)ViewBag.datasource)
                .AllowGrouping()
                .GroupSettings(group => { group.EnableDropAreaAnimation(false); })
                .Columns(col =>
                {
                    col.Field("LeagueID").IsPrimaryKey(true).HeaderText("ID").Width(50).Add();

                    col.Field("LeagueName").HeaderText("League").Add();
                    col.Field("Teams").HeaderText("Teams").Width(60).Add();
                    col.Field("WinPoint").HeaderText("Win").Width(50).Add();
                    col.Field("DrawPoint").HeaderText("Draw").Width(50).Add();
                    col.Field("GroupName").HeaderText("Group").Width(60).Add();
                    col.Field("CreatedBy").HeaderText("Created By").Width(150).Add();
                    col.Field("UpdatedBy").HeaderText("Updated By").Width(150).Add();

                    col.HeaderText("").Template("<a rel='nofollow' href='/Leagues/Edit/{{:LeagueID}}' rel='tooltip' title='Edit'><i class='glyphicon glyphicon-pencil'></i></a>").AllowFiltering(false).Width(50).Add();
                    col.HeaderText("").Template("<a rel='nofollow' href='/Leagues/Details/{{:LeagueID}}' rel='tooltip' title='Details'><i class='glyphicon glyphicon-list'></i></a>").AllowFiltering(false).Width(50).Add();
                    col.HeaderText("").Template("<a rel='nofollow' href='/Leagues/Details/{{:LeagueID}}' rel='tooltip' title='Fixtures'><i class='glyphicon glyphicon-stats'></i></a>").AllowFiltering(false).Width(50).Add();

                })
                .ChildGrid(child =>
                {
                    child.Datasource((IEnumerable<vwTeamList>)ViewBag.datasourcechild)
                        .QueryString("LeagueId")
                        .AllowPaging()
                        .Columns(col =>
                        {
                            col.Field("TeamId").Add();
                        })
                        ;



                })

result:

no resords to disly in child grid 

any thoughts ??

thnks

G



3 Replies

VA Venkatesh Ayothi Raman Syncfusion Team February 6, 2017 07:24 AM UTC

Hi Grant, 
Thanks for contacting Syncfusion support. 
We went through your code example that you have shared for us and found that you have passed wrong field in query string. This is cause of the issue, because QueryString property that has to be specified within the ChildGrid, which defines the relation between the parent and child grid.  
The QueryString property is used to denote the primaryKey field of the parent grid which is to be mapped with the foreignKey field of the child grid. In your code example, primary key of the parent grid is “LeagueID”. But you have passed the field name as “LeagueId” in QueryString property. 
Please refer to the following correct code example and help documentation for more information, 
Code example: 
@Grid 
 
@(Html.EJ().Grid<vwleague>("leagues") 
        .Datasource((IEnumerable<vwleague>)ViewBag.datasource) 
            .AllowGrouping() 
            .GroupSettings(group => { group.EnableDropAreaAnimation(false); }) 
            .Columns(col => 
            { 
            col.Field("LeagueID").IsPrimaryKey(true).HeaderText("ID").Width(50).Add(); 
             . . . 
               
            }) 
            .ChildGrid(child => 
            { 
            child.Datasource((IEnumerable<vwteamlist>)ViewBag.datasourcechild) 
                .QueryString("LeagueID") //here we can pass the field which is primary key of parent field 
                .AllowPaging() 
                .Columns(col => 
                { 
                col.Field("TeamId").Add(); 
                }) 
                ; 
 
    }); 
 
                }) 
 
Please let us know, if you have any further assistance on this. 

Regards, 
Venkatesh Ayothiraman. 



GS Grant Stephen February 7, 2017 08:30 AM UTC

Many thanks,

 All good now

Grant


VA Venkatesh Ayothi Raman Syncfusion Team February 8, 2017 10:26 AM UTC

Hi Grant, 
Thanks for the feedback. 
We are very happy to hear that your requirement is achieved. 
Regards, 
Venkatesh Ayothiraman. 


Loader.
Up arrow icon