- Home
- Forum
- ASP.NET MVC - EJ 2
- Will Hierarchy grid works for many to many associated data
Will Hierarchy grid works for many to many associated data
I had many to many associated table sample data will be like the below sample,
I need to show company details as the parent and employee details as the child.
Also i need to edit the employee details,
I have tried the Hierarchy grid MVC Syncfusion EJS 1, But it the field name provided in querystring need to be in the child data, In Many to Many associated data it won't have.
Please suggest me any to get it work.
[
{
"companyId": "1",
"name": "ACME, SL",
"employees": "50",
"contacts": [
{
"employeeId": "1",
"name": "John",
"surename": "Smith",
"department": "Finanzes"
},
{
"employeeId": "2",
"name": "Alex",
"surename": "Sanchez",
"department": "Support"
},
{
"employeeId": "3",
"name": "Carmen",
"surename": "Calvo",
"department": "Finanzes"
}
]
},
{
"companyId": "2",
"name": "Trendsuper Inc.",
"employees": "30",
"contacts": [
{
"employeeId": "1",
"name": "John",
"surename": "Smith",
"department": "Finanzes"
},
{
"employeeId": "2",
"name": "Alex",
"surename": "Sanchez",
"department": "Support"
},
{
"employeeId": "3",
"name": "Carmen",
"surename": "Calvo",
"department": "Finanzes"
},
{
"employeeId": "4",
"name": "John",
"surename": "Wartong",
"department": "Labs"
},
{
"employeeId": "5",
"name": "Quentin",
"surename": "Tarantino",
"department": "Support"
},
{
"employeeId": "6",
"name": "Josh",
"surename": "Sheldon",
"department": "IT"
}
]
},
{
"companyId": "3",
"name": "Cacatua Inc.",
"employees": "10",
"contacts": [
{
"employeeId": "4",
"name": "John",
"surename": "Wartong",
"department": "Labs"
},
{
"employeeId": "5",
"name": "Quentin",
"surename": "Tarantino",
"department": "Support"
},
{
"employeeId": "6",
"name": "Josh",
"surename": "Sheldon",
"department": "IT"
},
{
"employeeId": "8",
"name": "Walter",
"surename": "Distey",
"department": "Labs"
},
{
"employeeId": "9",
"name": "Quentin",
"surename": "Danubio",
"department": "Support"
}
]
}
]
SIGN IN To post a reply.
1 Reply
HJ
Hariharan J V
Syncfusion Team
May 14, 2019 01:19 PM UTC
Hi Saivikki,
Thanks for contacting Syncfusion support,
We have prepared sample based on your requirement. We have achieved your requirement using “Created”, “dataBound”,”detailDataBound” events of the EJ2 Grid. Please find the below code snippet and Sample documentation links for your reference.
|
@{
var ChildGrid1 = new Syncfusion.EJ2.Grids.Grid()
{
DataSource = ViewBag.empData,
QueryString = "EmployeeID",
Created ="created",
DataBound="dataBound",
. . .
}
};
}
<ejs-grid id="PublishedGrid" dataSource="ViewBag.data" childGrid="ChildGrid1" detailDataBound="detailDataBound" allowPaging="true" >
. . .
</ejs-grid>
<script>
var val;
var flag = 1;
function detailDataBound(args) {
val = args.data;
}
function created(args) {
flag = 1;
}
function dataBound(args) {
if (flag) {
var pre = [];
// You can handle many unique columns(querystring) in Child Grid
pre.push(new ej.data.Predicate('EmployeeID', 'equal', val["EmployeeID"]));
pre.push(new ej.data.Predicate('orderid', 'equal', val["OrderID"]));
this.query = new ej.data.Query().where(new ej.data.Predicate.and(pre));
this.refresh();
flag = 0;
}
}
</script> |
Sample: http://www.syncfusion.com/downloads/support/directtrac/234622/ze/ChildGrid_-2346221573792328.zip
Documentation Link: https://ej2.syncfusion.com/documentation/api/grid/#created
Please get back to us if you need further assistance.
Regards,
Hariharan
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
SA saivikki
- May 11, 2019 09:22 AM UTC
- May 14, 2019 01:19 PM UTC