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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

HierarchyGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

128657 Feb 3,2017 09:31 AM UTC Feb 8,2017 10:26 AM UTC ASP.NET MVC 3
loading
Tags: Grid
Grant Stephen
Asked On February 3, 2017 09:31 AM UTC

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



Venkatesh Ayothi Raman [Syncfusion]
Replied On 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. 


Grant Stephen
Replied On February 7, 2017 08:30 AM UTC

Many thanks,

 All good now

Grant

Venkatesh Ayothi Raman [Syncfusion]
Replied On 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. 


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.

Warning Icon 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.Close Icon

;