- Home
- Forum
- ASP.NET MVC - EJ 2
- About hierarchical bindings of grid
About hierarchical bindings of grid
Hi,
Is it possible to do hierarchical binding easily without using "QueryString" for parent-child relationship view models as follows?
class ParentViewModel { public string ParentName { get; set; } public List<ChildViewModel> Children { get; set; } } class ChildViewModel { public string ChildName { get; set; } } |
Regards,
Pylori.
SIGN IN To post a reply.
3 Replies
PS
Pavithra Subramaniyam
Syncfusion Team
April 1, 2019 04:54 AM UTC
Hi Pylori,
Thanks for contacting Syncfusion support.
Query : Is it possible to do hierarchical binding easily without using "QueryString" for parent-child relationship view models as follows?
No, The child Grid is bounded to the Parent row based on the “queryString” relation only. So defining the ‘queryString’ property is essential for the Hierarchical Binding feature.
Regards,
Pavithra S.
PY
Pylori
April 1, 2019 10:54 AM UTC
Hi Pavithra S,
Thank you for answering.
Implement using "QueryString".
Regards,
Pylori.
PS
Pavithra Subramaniyam
Syncfusion Team
April 2, 2019 08:39 AM UTC
Hi Pylori,
Thanks for the update.
We would like to explain the “Hierarchical binding in Grid”. The Grid will display as a hierarchy(parent-child) when the dataSource of the parent and child Grid have a common “field” name(which will be used as the value for “QueryString”), and by comparing the values of this field name, the child Grid will be displayed.
Based on the shared model, we have prepared a sample by binding same dataSource for both child and parent Grids. We have achieved this requirement by using the “created” event of Child Grid. Please refer the code example and sample link below,
Sample : http://www.syncfusion.com/downloads/support/directtrac/general/ze/gridmvclocalization-2016728499
|
[Index.cshtml]
<div>
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.datasource).AllowPaging().Columns(col =>
{
...
})...Load("load").Render()
</div>
<script>
var data = @Html.Raw(Json.Encode(ViewBag.datasource));
function load(args) {
var grid = document.getElementById('Grid').ej2_instances[0]
grid.childGrid = {
dataSource: data,
queryString: 'EmployeeID',
created:created,
...
}
}
function created(args) {
this.dataSource = this.parentDetails.parentRowData.Employee; //Bind the data to Child Grid
}
</script>
|
Documentations :
Please get back to us if you need further assistance.
Regards,
Pavithra S.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
PY Pylori
- Mar 30, 2019 02:45 AM UTC
- Apr 2, 2019 08:39 AM UTC